最新
动画Fade In On Scroll
Content that fades and rises into place as it enters the viewport.
#scroll#reveal#fade
6 个框架中级
Content that slides and fades in from a chosen edge as it enters view.
<!-- The observer watches only this element, not the window. -->
<div class="reveal-slide max-w-sm translate-x-[-40px] opacity-0 transition-[transform,opacity] duration-700 ease-out motion-reduce:transition-none" data-reveal-slide>
<div class="rounded-2xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-800 dark:bg-gray-900">
<h3 class="text-base font-semibold text-gray-900 dark:text-gray-100">Slides into view</h3>
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Reveal panels as they enter the viewport, from any direction.</p>
</div>
</div>
<noscript><style>[data-reveal-slide]{opacity:1 !important;transform:none !important;}</style></noscript>
<script>
(function () {
var el = document.querySelector('[data-reveal-slide]');
if (!el) return;
function show() { el.style.opacity = '1'; el.style.transform = 'translate(0,0)'; }
if (!('IntersectionObserver' in window) || window.matchMedia('(prefers-reduced-motion: reduce)').matches) { show(); return; }
var obs = new IntersectionObserver(function (entries) {
entries.forEach(function (e) { if (e.isIntersecting) { show(); obs.disconnect(); } });
}, { threshold: 0.2 });
obs.observe(el);
})();
</script>| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
children必填 | ReactNode | - | 在组件内部渲染的内容。 |
from | 'left' | 'right' | 'up' | 'down' | 'left' | From |
distance | number | 40 | 元素移动的距离(像素)。 |
once | boolean | true | 仅在首次进入视口时播放动画。 |
className | string | '' | 合并到根元素上的额外类名。 |
Pick the `from` edge and `distance`; set `once={false}` to replay on re-entry. The observer watches only this element and reduced motion shows it immediately.