This repository was archived by the owner on Sep 21, 2024. It is now read-only.
generated fromryanatkn/fuz_template
- Notifications
You must be signed in to change notification settings - Fork0
a Svelte action for IntersectionObserver
License
NotificationsYou must be signed in to change notification settings
ryanatkn/svelte-intersect
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
⚠️ deprecated, moved to@ryanatkn/fuz/intersect.js
- demo:ryanatkn.github.io/svelte-intersect
- npm:
svelte-intersect - Svelterepl
- todo
- figure out how to make the
eltype inferred/generic - does the API need any tweaks? (the negative
countnever disconnecting may be undesirable)
- figure out how to make the
npm i -D svelte-intersect
import{intersect}from'svelte-intersect';
intersect is aSvelte actionthat callsonintersect whenel enters or leavestheviewport:
<divuse:intersect={{onintersect: ({intersecting,intersections,el,observer,disconnect})=>void,ondisconnect: ({intersecting,intersections,el,observer})=>void,count:1,// 1 is like 'once', 0 disables, <0 or undefined is infiniteoptions: {threshold,root,rootMagin},// `IntersectionObserver` options}}>
All options are optional.
exportinterfaceIntersect_Params{/** * Called when the element enters or leaves the viewport until disconnected. */onintersect?:On_Intersect;/** * Called when the action's observer is disconnected, * either by the user calling disconnect or the action being destroyed. */ondisconnect?:On_Disconnect;/** * A value of `1` disconnects after `el` enters and leaves the viewport one time, * similar to 'once' for an event. * `0` disables and `undefined` or a negative number like `-1` never disconnects. */count?:number;/** * Same as the `options` param to * [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options) */options?:IntersectionObserverInit;}exportinterfaceOn_Intersect{(state:Intersect_State):void;}exportinterfaceIntersect_State{intersecting:boolean;intersections:number;el:HTMLElement|SVGElement;observer:IntersectionObserver;disconnect:()=>void;}exportinterfaceOn_Disconnect{(state:Disconnect_State):void;}exportinterfaceDisconnect_State{intersecting:boolean;intersections:number;el:HTMLElement|SVGElement;observer:IntersectionObserver;}
For more see theIntersectionObserver docson MDN, the demo atryanatkn.github.io/svelte-intersect,andthe implementation.
About
a Svelte action for IntersectionObserver
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.