Overview
onIntersect({ onVisible?, onHidden?, rootMargin?, threshold? }) wraps IntersectionObserver as an element directive. Callbacks fire with no entry argument — keep them lightweight.
onVisible(cb, opts?) and onHidden(cb, opts?) are shortcuts that only register one side of the transition.
onIntersect vs shortcuts
|
API
|
Fires on
|
Notes
|
|---|---|---|
onIntersect({…})
| Enter and/or leave | Full options object; both callbacks optional. |
onVisible(cb, opts?)
| Enter only | Handy for infinite-scroll sentinels and prefetch. |
onHidden(cb, opts?)
| Leave only | Pause media, stop work when off-screen. |
Scroll-triggered reveal
onIntersect wraps IntersectionObserver as an element directive. Each item fades and slides in the first time it scrolls into view. The observer is automatically disconnected when the element is removed.
onVisible shortcut
onVisible(cb) fires when the element enters the viewport — handy for infinite-scroll sentinels.