最新
动画Stagger Reveal Grid
Grid items that fade and slide up in sequence as the grid enters the viewport.
#stagger#reveal#grid
3 个框架中级
Content that fades and rises into place as it enters the viewport.
<section class="reveal" data-reveal>
<h2>Ship faster</h2>
<p>Everything you need to go from idea to production, in one place.</p>
</section>
<section class="reveal" data-reveal data-reveal-delay="120">
<h2>Scale calmly</h2>
<p>Autoscaling, observability, and rollbacks that take one click.</p>
</section>
<!-- Without JS the observer never runs, so unhide everything up front. -->
<noscript>
<style>
.reveal { opacity: 1 !important; transform: none !important; }
</style>
</noscript>
<script>
(function () {
var nodes = document.querySelectorAll('[data-reveal]');
// No observer support, or the user asked for less motion: show immediately.
if (
!('IntersectionObserver' in window) ||
window.matchMedia('(prefers-reduced-motion: reduce)').matches
) {
nodes.forEach(function (node) {
node.classList.add('is-visible');
});
return;
}
var observer = new IntersectionObserver(
function (entries) {
entries.forEach(function (entry) {
if (!entry.isIntersecting) return;
var node = entry.target;
node.style.transitionDelay = (node.dataset.revealDelay || 0) + 'ms';
node.classList.add('is-visible');
observer.unobserve(node);
});
},
{ threshold: 0.15, rootMargin: '0px 0px -10% 0px' }
);
nodes.forEach(function (node) {
observer.observe(node);
});
})();
</script>pnpm add framer-motion@^12.42.2
| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
children必填 | ReactNode | - | 在组件内部渲染的内容。 |
direction | 'up' | 'down' | 'none' | 'up' | 元素出现时的移动方向。 |
distance | number | 24 | 元素移动的距离(像素)。 |
delay | number | 0 | 入场动画前等待的秒数。 |
duration | number | 0.5 | 动画时长(秒)。 |
once | boolean | true | 仅在首次进入视口时播放动画。 |
Tune `duration` and the y-offset for a heavier or lighter entrance. Trigger once rather than on every scroll - re-animating content a reader has already seen is distracting.