shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
whenNearViewport
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.when
Monitor an HTMLElement to be notified when it is near (100vh before or after) the viewport, or in the viewport
Params
- $elm*-HTMLElement
The element to monitor
- settings{}Partial<TWhenNearViewportSettings>
Some settings to tweak the detection behavior
Return
- -(Promise<HTMLElement>)
The promise that will be resolved when the element is in the viewport
Example
import { whenNearViewport } from '@blackbyte/sugar/dom'
whenNearViewport($myCoolHTMLElement).then($elm => {
// do something with your element that has entered the viewport...
});Settings
- offset`${window.innerHeight}px ${window.innerWidth}px`String
Some offset
Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space