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. onScrolledIntoView(cb, opts?) fires only on a genuine hidden-to-visible crossing and skips the observer’s first report, so an element that is already on screen at mount does not trigger it.
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. |
onScrolledIntoView(cb, opts?)
| Enter after leave |
Skips the initial observation. lazyLoad is the deprecated alias.
|
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.
onScrolledIntoView
Fires on a real hidden-to-visible crossing. An element already in view at mount does not count. lazyLoad is the same function, marked deprecated.