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[]>

patch

patch: (storesValues) => void

Parameters

storesValues: Partial<IntersectionProps>

Returns

void

visibleElements$

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


IntersectionProps

interface

Interface representing the properties for the Intersection service.

Properties
elements

elements: HTMLElement[]

elements to observe


options

options: undefined | Partial<IntersectionObserverInit>

IntersectionObserverInit used in the IntersectionObserver

See

MDN documentation