Skip to content

Instantly share code, notes, and snippets.

@phpmaps
Created March 17, 2021 14:43
Show Gist options
  • Select an option

  • Save phpmaps/1fc0ad4de127f9f1e2295f7a4fcd94c4 to your computer and use it in GitHub Desktop.

Select an option

Save phpmaps/1fc0ad4de127f9f1e2295f7a4fcd94c4 to your computer and use it in GitHub Desktop.
onScrollStop
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