Skip to content

Instantly share code, notes, and snippets.

@nikkow
Last active August 29, 2015 14:16
Show Gist options
  • Save nikkow/9e249af14d8607c5f649 to your computer and use it in GitHub Desktop.
Save nikkow/9e249af14d8607c5f649 to your computer and use it in GitHub Desktop.
Disable "bounce" effect in NW.js
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();
@nikkow
Copy link
Author

nikkow commented May 26, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment