Skip to content

Instantly share code, notes, and snippets.

@cscuderi
Last active December 30, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cscuderi/7754665 to your computer and use it in GitHub Desktop.
Save cscuderi/7754665 to your computer and use it in GitHub Desktop.
JavaScript that toggles a universal class on scroll to disable pointer events. Removes the class when the user stops scrolling. From http://www.thecssninja.com/javascript/pointer-events-60fps
.disable-hover,
.disable-hover * {
pointer-events: none !important;
}
var body = document.body,
timer;
window.addEventListener('scroll', function() {
clearTimeout(timer);
if(!body.classList.contains('disable-hover')) {
body.classList.add('disable-hover')
}
timer = setTimeout(function(){
body.classList.remove('disable-hover')
},500);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment