Skip to content

Instantly share code, notes, and snippets.

@TexRx
Created March 20, 2014 08:08
Show Gist options
  • Save TexRx/9659305 to your computer and use it in GitHub Desktop.
Save TexRx/9659305 to your computer and use it in GitHub Desktop.
pointer events disable scroll 60 fps
/**
* Disable and enable event on scroll begin and scroll end.
* @see http://www.thecssninja.com/javascript/pointer-events-60fps
*/
var root = document.documentElement;
var timer;
window.addEventListener('scroll', function() {
// User scrolling so stop the timeout
clearTimeout(timer);
// Pointer events has not already been disabled.
if (!root.style.pointerEvents) {
root.style.pointerEvents = 'none';
}
timer = setTimeout(function() {
root.style.pointerEvents = '';
}, 500);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment