npm
npm i @shaaditech/scroll-handler
yarn
yarn add @shaaditech/scroll-handler
To register the callback when the element appears in the viewport.
registerScrollToView(element, scrollPosition => {}, false, 0)
Parameters | type | example |
---|---|---|
element | html element node | document.getElementById('header') |
callback | function | scrollPosition => {} |
allowNext | boolean (default false) | true/false |
delay (milliseconds) | int (default 0) | 1000 |
This function unregisters the element. Here, the second parameter is callback function which will be called when the element is unregistered.
To check if the element is in viewport.
If you have an issue, feel free to contact me @shivamsupr