Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidhellsing/3e2e7bd78e09e208888122856cc9e211 to your computer and use it in GitHub Desktop.
Save davidhellsing/3e2e7bd78e09e208888122856cc9e211 to your computer and use it in GitHub Desktop.
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