public
Last active

Added iOS and Android Support for jScrollPane

  • Download Gist
jscrollpane.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// Ipad Iphone
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))||(navigator.userAgent.match(/Android/i))) {
var isTouchScreen = 1;
}else{
var isTouchScreen = 0;
}
$container.bind('touchstart', function(e){
var cpos = dragPosition;
if(isTouchScreen){
e = e.originalEvent.touches[0];
}
var sY = e.pageY;
var sX = e.pageX;
$container.bind('touchmove',function(ev){
if(isTouchScreen){
ev.preventDefault();
ev = ev.originalEvent.touches[0];
}
var top = cpos-(ev.pageY-sY);
positionDrag(top);
 
});
$container.bind('touchend',function(ev){
$container.unbind('touchmove touchend');
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.