Skip to content

Instantly share code, notes, and snippets.

@rmdort
Created December 19, 2010 09:51
Show Gist options
  • Save rmdort/747229 to your computer and use it in GitHub Desktop.
Save rmdort/747229 to your computer and use it in GitHub Desktop.
Added iOS and Android Support for jScrollPane
// 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');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment