export type ScrolledIntoViewCallback = () => void; export interface ScrolledIntoViewOptions { /** * Margin around the viewport in CSS syntax (e.g. `"200px"` or `"10%"`). * Positive values trigger the callback before the element is fully visible. * Default: `"0px"` */ rootMargin?: string; /** * Intersection ratio threshold (0–1) at which the callback fires. * Default: `0` */ threshold?: number; } /** @deprecated Use `ScrolledIntoViewCallback` instead. */ export type LazyLoadCallback = ScrolledIntoViewCallback; /** @deprecated Use `ScrolledIntoViewOptions` instead. */ export type LazyLoadOptions = ScrolledIntoViewOptions; /** * Fires `callback` each time the element transitions from hidden to visible * in the viewport (a genuine invisible → visible crossing). * * - Does **not** fire on mount if the element is already in view. * - Fires **again** every time the element re-enters the viewport after * having left it — useful for infinite scroll, repeat animations, etc. * - The `IntersectionObserver` is torn down automatically when the element * disconnects from the DOM — no manual cleanup needed. * - `options` are fixed at creation time and cannot change between renders; * only the `callback` reference is updated on re-renders. * * @param callback - Called whenever the element scrolls into view. * @param options - Optional `IntersectionObserver` tuning. * * @example * ```ts * // Infinite scroll — load next page when sentinel enters the viewport * html`