Created
June 22, 2016 11:59
-
-
Save davidhellsing/3e2e7bd78e09e208888122856cc9e211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keys = [37, 38, 39, 40] | |
var prevent = (e) => { | |
if ( e.type != 'keydown' || keys.indexOf(e.keyCode) != -1 ) { | |
e.preventDefault() | |
return false | |
} | |
} | |
var disableScroll = (node) => { | |
node = node || window | |
node.onwheel = node.ontouchmove = document.onkeydown = prevent | |
} | |
var enableScroll = (node) => { | |
node = node || window | |
node.onwheel = node.ontouchmove = document.onkeydown = null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment