Created
March 17, 2021 14:43
-
-
Save phpmaps/1fc0ad4de127f9f1e2295f7a4fcd94c4 to your computer and use it in GitHub Desktop.
onScrollStop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const onScrollStop = (el, callback) => { | |
| if (!callback || typeof callback !== 'function') return; | |
| if(!el) return; | |
| let isScrolling; | |
| el.addEventListener('scroll', (event) => { | |
| el.clearTimeout(isScrolling); | |
| isScrolling = setTimeout(() => { | |
| callback(); | |
| }, 70); | |
| }, false); | |
| }; | |
| onScrollStop( () => { | |
| console.log('Scrolling stopped.'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment