Last active
April 4, 2018 15:22
-
-
Save Jekins/c9a16bfbfa8c5db2e89709a8da4b15d7 to your computer and use it in GitHub Desktop.
Выключить сколл
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
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