Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 21, 2024. It is now read-only.

a Svelte action for IntersectionObserver

License

NotificationsYou must be signed in to change notification settings

ryanatkn/svelte-intersect

Repository files navigation

⚠️ deprecated, moved to@ryanatkn/fuz/intersect.js

aSvelte action forIntersectionObserver

Usage

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.

License

MIT

About

a Svelte action for IntersectionObserver

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp