Skip to content

Instantly share code, notes, and snippets.

@foleyatwork
Last active August 29, 2015 13:56
Show Gist options
  • Save foleyatwork/8969411 to your computer and use it in GitHub Desktop.
Save foleyatwork/8969411 to your computer and use it in GitHub Desktop.
Disables all pointer events on scroll for 60fps scrolling. Thanks to Paul Irish (source: http://www.thecssninja.com/javascript/pointer-events-60fps).
(function () {
var css = '.disable-hover, .disable-hover * { pointer-events: none !important; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style'),
body = document.body,
timer;
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
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')
},300);
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment