@svelte-put/intersect
v4.0.0
Published
Action that wraps IntersectionObserver
Downloads
721
Maintainers
Readme
@svelte-put/intersect
Svelte action use:intersect
- wrapper for IntersectionObserver
svelte-put
This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.
Usage & Documentation
See the dedicated documentation page here.
Quick Start
<script lang="ts">
import { intersect, type IntersectDetail } from '@svelte-put/intersect';
function onIntersect(e: CustomEvent<IntersectDetail>) {
const { observer, entries, direction } = e.detail;
console.log('the observer itself', observer);
console.log('scrolling direction:', direction);
console.log('intersecting:', entries[0]?.isIntersecting ? 'entering' : 'leaving');
}
</script>
<div use:intersect onintersect={onIntersect} onintersectonce></div>