intersect.svelte.ts

Declarations
#

7 declarations

view source

DisconnectState
#

intersect.svelte.ts view source

DisconnectState

intersecting

type boolean

intersections

type number

el

type HTMLElement | SVGElement

observer

type IntersectionObserver

intersect
#

intersect.svelte.ts view source

(get_params: () => IntersectParamsOrCallback | null | undefined): Attachment<HTMLElement | SVGElement>

Creates an attachment that observes element viewport intersection. Uses the lazy function pattern to optimize reactivity: callbacks can update without recreating the observer, preserving state.

get_params

Function that returns callback, params object, or nullish to disable

type () => IntersectParamsOrCallback | null | undefined

returns

Attachment<HTMLElement | SVGElement>

IntersectParams
#

intersect.svelte.ts view source

IntersectParams

onintersect

Called when the element enters or leaves the viewport until disconnected.

ondisconnect

Called when the attachment's observer is disconnected, either by the user calling disconnect or the attachment being destroyed.

count

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.

type number

options

Same as the options param to IntersectionObserver

type IntersectionObserverInit

IntersectParamsOrCallback
#

IntersectState
#

intersect.svelte.ts view source

IntersectState

intersecting

type boolean

intersections

type number

el

type HTMLElement | SVGElement

observer

type IntersectionObserver

disconnect

type () => void

OnDisconnect
#

OnIntersect
#

Imported by
#