/ Published in: jQuery
Add this code to jscrollpane.js
Expand |
Embed | Plain Text
// 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'); }); });
Comments
Subscribe to comments
You need to login to post a comment.

I think you left out a closing bracket at the end of the script:
});
That being said, I still can't get this to work. Whether I put your code at the top or bottomw of jscrollpane.js, I get "$container is not defined". Can you offer more details on how to get this to work? Do I need a specific version of jScrollPane?
Thanks!
I get it work !
Just place the code after
if (isScrollable) { (arround line 165)
Thx for the code, working for on android too ^^
And for android (i forgot), add this
|| (navigator.userAgent.match(/Android/i))
after
(navigator.userAgent.match(/iPad/i))
And yes i confirm about the closing bracket missing ^^
Thanks Xeldar! I've now got it working as well. I was adding the snippet into the wrong section. Appreciate the help!
Sorry guys. been a little busy.. I did miss out the closing bracket.. Updated the code :)
I still can't seem to figure out where to past this code. There is no: if (isScrollable) { in my jscrollpane.js file. There are a few if (isScrollableV) or if (isScrollableH) {
So, could you please just post the entire jscrollpane.js with your code? Or just tell me where I'm going wrong.
Scrollpane works on IPad and Android but gives a problem on the IPhone: it scrolles only halfway. please take a look at http://www.womeninwood.nl/werkwijze.html (there is more content then it shows).
When we place this code snippet it is workign fine on Ipad but it is throwing errors on IE desktop. Can someone please suggest if there is anyti=hign that needs to be changed. Any help is much appreciated. Thanks in advance!
Hello I'm not very experienced with js, could someone tell me the correct placement for this code (as someone already mentioned there is no if (isScrollable) { (arround line 165) )
I'm confused, are your divs called touchstart or is that required?
Also does this allow for horizontal scrolling on iphone/ipad?
I just created a acount for you to say THANKS. Its really sovle my problem. Thanks once again :)