Skip to main content

use_intersection_observer

Function use_intersection_observer 

Source
pub fn use_intersection_observer() -> UseIntersectionObserver
Expand description

Obtains the UseIntersectionObserver registered against the current hook context slot.

Behaves like HookContext::use_hook - the same handle is returned on every render at the same hook index, so the observer is created once and the visibility survives re-renders.

Attach get_target() to the caller’s markup with the ref: attribute, then read get_visible() inside a render closure to react to the element entering or leaving the viewport.

§Returns

  • UseIntersectionObserver - The handle, with get_target() returning the NodeRef and get_visible() the reactive Signal<bool>.