Last active
August 29, 2015 14:16
-
-
Save nikkow/9e249af14d8607c5f649 to your computer and use it in GitHub Desktop.
Disable "bounce" effect in NW.js
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 keysToDisable = [37, 38, 39, 40, 33, 34, 35, 36]; | |
function preventDefault(e) { | |
e = e || window.event; | |
if (e.preventDefault) { | |
e.preventDefault(); | |
} | |
e.returnValue = false; | |
} | |
function keydown(e) { | |
for (i = 0; i < keysToDisable.length; i++) { | |
if (e.keyCode === keysToDisable[i]) { | |
preventDefault(e); | |
return; | |
} | |
} | |
} | |
function wheel(e) { | |
preventDefault(e); | |
} | |
function noScroll() { | |
window.onmousewheel = document.onmousewheel = wheel; | |
document.onkeydown = keydown; | |
} | |
noScroll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems to only affect 0.12-alpha3 version of nwjs. The CSS trick described in #3109 is working fine with the latest version (0.12.2) and does not block the scroll on the entire page.