Posted By

Xeldar on 10/01/10


Tagged

plugin jquery iphone support android ipod iPad ios jscrollpane


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Xeldar
bobbym245
Balamir


JSCROLLPANE IPAD/IPHONE/IPOD/IOS SCROLL/ANDROID SUPPORT


 / Published in: jQuery
 

From http://snipplr.com/view/41051/jscrollpane-ipadiphoneipodios-scoll-support/ here the part of code to add in jScrollPane.js for android,iphone,ipod,ipad support. Add this after :if (isScrollable) { (around line 165)

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

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: JasonCo on October 14, 2010

I can't get this to work. Would you mind clarifying exactly where this snippet of code should be pasted? Line 165 is in the middle of a block of comments and there are a few if (scrollable) statements near that block of code. Any help is appreciated and thanks in advance.

~Jason

Posted By: larssonk22 on January 7, 2012

couldnt get it to work either

You need to login to post a comment.