Skip to content

Instantly share code, notes, and snippets.

@t0mtaylor
Last active August 29, 2015 14:02
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 t0mtaylor/535741f5aa5f29dda922 to your computer and use it in GitHub Desktop.
Save t0mtaylor/535741f5aa5f29dda922 to your computer and use it in GitHub Desktop.
/**
* Disable and enable event on scroll begin and scroll end.
*
* Quick tidy, auto for active hover styles, and set in self executing method
* Check for addEventListener, don't bother with IE8 and older browsers
* Tom Taylor - 03/06/14 - http://tommytaylor.co.uk
*
* @see http://www.thecssninja.com/javascript/pointer-events-60fps
*/
(function(w, d) {
var doc = d.documentElement || d.body,
timer;
if (w.addEventListener) {
w.addEventListener('scroll', function() {
w.clearTimeout(timer);
if(!doc.style.pointerEvents) {
doc.style.pointerEvents = 'none';
}
timer = w.setTimeout(function() {
doc.style.pointerEvents = 'auto';
}, 200);
}, false);
}
})(window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment