Skip to content

UseObserverCreate

katanakit-js / useObserverCreate

function useObserverCreate(
key,
callback,
options?,
autoUnobserve?
): void;

Defined in: infrastructure/observer/observer.service.ts:70

Creates an IntersectionObserver under the given key. If an observer with the same key already exists, it is disconnected first.

Parameter Type Default value Description
key string undefined A unique identifier for this observer.
callback ObserverCallback undefined Invoked when an observed element enters the viewport.
options? IntersectionObserverInit ... IntersectionObserver options (default: { threshold: 0.1 }).
autoUnobserve? boolean true Whether to automatically unobserve after first intersection (default: true).

void

useObserverCreate("hero", (entry) => {
console.log("Hero is visible!", entry.target);
}, { threshold: 0.5 });