vsbl
In-viewport detection without event listeners. 440 bytes gzipped.
Install
npm i vsbl --save
Usage
const enter = {}const exit = {} const listener = enter exit // destroy
Options
threshold
Trigger visibility sooner or later than usual.
- Values below
0.5
will be treated as a percentage of the viewport - Values of
0.5
and over will be considered pixel values
const listener = console
You can optionally include this threshold as an attribute on the element itself:
License
MIT License © Eric Bailey