Created
July 27, 2016 12:32
-
-
Save xto3na/7ad47d7fb00cb5ba240e957797a1a52d to your computer and use it in GitHub Desktop.
SWIPE
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
$.fn.touchScrolling = function(){ | |
var startPos = 0, | |
self = $(this); | |
self.bind('touchstart', function(event) { | |
console.info("touchstart, target: ", event.target); | |
var e = event.originalEvent; | |
startPos = self.scrollTop() + e.touches[0].pageY; | |
e.preventDefault(); | |
}); | |
self.bind('touchmove', function(event) { | |
console.info("touchmove, target: ", event.target); | |
var e = event.originalEvent; | |
self.scrollTop(startPos - e.touches[0].pageY); | |
e.preventDefault(); | |
}); | |
}; | |
$(function() { | |
$('#touch-scroll').touchScrolling(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment