Skip to content

Instantly share code, notes, and snippets.

@Jekins
Last active April 4, 2018 15:22
Show Gist options
  • Save Jekins/c9a16bfbfa8c5db2e89709a8da4b15d7 to your computer and use it in GitHub Desktop.
Save Jekins/c9a16bfbfa8c5db2e89709a8da4b15d7 to your computer and use it in GitHub Desktop.
Выключить сколл
if ($(window).width() < 992) {
var _overlay = document.getElementsByClassName('no-scrolling');
var _clientY = null;
for (var i = 0; i < _overlay.length; i++) {
_overlay[i].addEventListener('touchstart', function (event) {
if (event.targetTouches.length === 1) {
_clientY = event.targetTouches[0].clientY;
}
}, false);
_overlay[i].addEventListener('touchmove', function (event) {
if (event.targetTouches.length === 1) {
disableRubberBand(event, this);
}
}, false);
}
function disableRubberBand(event, el) {
var clientY = event.targetTouches[0].clientY - _clientY;
if (el.scrollTop === 0 && clientY > 0) {
event.preventDefault();
}
if (isOverlayTotallyScrolled(el) && clientY < 0) {
event.preventDefault();
}
}
function isOverlayTotallyScrolled(el) {
return el.scrollHeight - el.scrollTop <= el.clientHeight;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment