Releases: metonym/svelte-intersection-observer
Releases · metonym/svelte-intersection-observer
v1.1.1
v1.1.0
Features
For performance, use MultipleIntersectionObserver to observe multiple elements. This avoids creating standalone observers per component.
<script>
import { MultipleIntersectionObserver } from "svelte-intersection-observer";
let ref1;
let ref2;
$: elements = [ref1, ref2];
</script>
<MultipleIntersectionObserver {elements} let:elementIntersections>
<header>
<div class:intersecting={elementIntersections.get(ref1)}>
Item 1: {elementIntersections.get(ref1) ? "✓" : "✗"}
</div>
<div class:intersecting={elementIntersections.get(ref2)}>
Item 2: {elementIntersections.get(ref2) ? "✓" : "✗"}
</div>
</header>
<div bind:this={ref1}>Item 1</div>
<div bind:this={ref2}>Item 2</div>
</MultipleIntersectionObserver>v1.0.0
Breaking Changes
- Drop support for bundled ESM/UMD; code is only distributed as Svelte files
- Remove
IntersectionObserverPropsorEntryTypeScript interfaces fromIntersectionObserver.svelte.d.ts
Use the Svelte ComponentProps utility to extract component props.
import IntersectionObserver from "svelte-intersection-observer";
import type { ComponentProps } from "svelte";
type Props = ComponentProps<IntersectionObserver>;Fixes
elementandrootprop types should benull | HTMLElementto support TypeScript strict mode- Add
exportsfield topackage.json
v0.10.2
v0.10.1
v0.10.0
v0.9.2
v0.9.1
v0.9.0
- improve TypeScript definitions for dispatched events
on:observe:event.detail.isIntersectingis abooleanon:intersect:event.detail.isIntersectingcan only betrue
<IntersectionObserver
on:observe={(e) => {
console.log(e.detail.isIntersecting); // boolean
}}
on:intersect={(e) => {
console.log(e.detail.isIntersecting); // true
}}
/>