Skip to content

Instantly share code, notes, and snippets.

@Lysindr
Created November 16, 2018 15:45
Show Gist options
  • Save Lysindr/0fbc08df65df3a11e52a3854d2fa45b6 to your computer and use it in GitHub Desktop.
Save Lysindr/0fbc08df65df3a11e52a3854d2fa45b6 to your computer and use it in GitHub Desktop.
Disable body scroll (work on Safari, IOS)
// Prevent body scroll (try fixed issue on IOS)
var freezeVp = function(e) {
e.preventDefault();
};
function stopBodyScrolling (bool) {
if (bool === true) {
document.body.addEventListener("touchmove", freezeVp, false);
console.log(222);
} else {
document.body.removeEventListener("touchmove", freezeVp, false);
}
}
/*
call function with *true* argument, if you need BLOCK SCROLL: stopBodyScrolling(true);
or with *false* argument, to ENABLE scroll stopBodyScrolling(false)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment