Skip to content

Instantly share code, notes, and snippets.

@xto3na
Created July 27, 2016 12:32
Show Gist options
  • Save xto3na/7ad47d7fb00cb5ba240e957797a1a52d to your computer and use it in GitHub Desktop.
Save xto3na/7ad47d7fb00cb5ba240e957797a1a52d to your computer and use it in GitHub Desktop.
SWIPE
$.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