Bootstrap

API intersection

createIntersection

function

createIntersection(config?): object

Create an intersection service.

The returned service includes the patch method to set the elements to observe / intersection options and the states to track the visible elements.

Parameters

config?: PropsConfig<IntersectionProps>

the props config for the intersection service

Returns

object

the intersection service

elements$

elements$: ReadableSignal<HTMLElement[]>

Readable of observed elements

patch

patch: <U>(storesValues?) => void

Type Parameters

U extends Partial<IntersectionProps>

Parameters

storesValues?: void | U

Returns

void

visibleElements$

visibleElements$: ReadableSignal<Map<Element, IntersectionObserverEntry>>

Store of map that contains the visible elements (for the key) and the corresponding entries

See the MDN documentation


IntersectionProps

interface
Properties
elements

elements: HTMLElement[]

elements to observe


options

options: undefined | Partial<IntersectionObserverInit>

IntersectionObserverInit used in the IntersectionObserver

See the MDN documentation