shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
whenEntersViewport
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.when
Monitor an HTMLElement to be notified when it is enters in the viewport (1/3vh in the viewport), or in the viewport
Params
- $elm*-HTMLElement
The element to monitor
- settings{}Partial<TWhenEntersViewportSettings>
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 { whenEntersViewport } from '@blackbyte/sugar/dom'
whenEntersViewport($myElement).then(($elm) => {
// do something with your element that has entered the viewport...
});Settings
- offset’0px 0px -25% 0px’String
An offset to detect the element entering in viewport earlier or later
Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space