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


/ Published in: jQuery
Save to your folder(s)

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)


Copy this code and paste it in your HTML
  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

You need to login to post a comment.