Created
November 16, 2018 15:45
-
-
Save Lysindr/0fbc08df65df3a11e52a3854d2fa45b6 to your computer and use it in GitHub Desktop.
Disable body scroll (work on Safari, IOS)
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
// 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