Last active
September 13, 2017 11:24
-
-
Save souljorje/46dcb3b88658a4104f633f62856a2eb7 to your computer and use it in GitHub Desktop.
Disable touch move for all elements except selected
This file contains hidden or 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).innerWidth() <= 980) { | |
| let scrollArea = document.querySelector(".selector"); | |
| scrollArea.addEventListener("touchstart", function(event) { | |
| this.previousClientY = event.touches[0].clientY; | |
| }); | |
| scrollArea.addEventListener("touchmove", function(event) { | |
| let scrollTop = this.scrollTop; | |
| let maxScroll = this.scrollHeight - this.offsetHeight; | |
| let currentClientY = event.touches[0].clientY; | |
| let deltaY = this.previousClientY - currentClientY; | |
| if ( (scrollTop === maxScroll && deltaY > 0) || (scrollTop === 0 && deltaY < 0) ) { | |
| event.preventDefault(); | |
| } | |
| this.previousClientY = currentClientY; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment