2012-06-12 23 views

回答

4

您對「構造」對象的禁用觸摸事件,就像這樣:

  root = $('#content').scrollable({ 
       keyboard:false, 
       mousewheel: false, 
       touch: false 
      }); 
2

我需要做類似的東西在那裏滾動是在iPad上的方式過於敏感。這是我改變,使之成爲水平刷卡不太敏感:

// touch event 
if (conf.touch) { 
    var touch = {}; 

    itemWrap[0].ontouchstart = function(e) { 
     var t = e.touches[0]; 
     touch.x = t.clientX; 
     touch.y = t.clientY; 
    }; 

    itemWrap[0].ontouchmove = function(e) { 

     // only deal with one finger 
     if (e.touches.length == 1 && !itemWrap.is(":animated")) {   
      var t = e.touches[0], 
       deltaX = touch.x - t.clientX, 
       deltaY = touch.y - t.clientY; 
      self[vertical && deltaY > 0 || !vertical && deltaX > 0 ? 'next' : 'prev']();     
      e.preventDefault(); 
     } 
    }; 
} 

變爲

// touch event 
if (conf.touch) { 
    var touch = {}; 

    itemWrap[0].ontouchstart = function(e) { 
     var t = e.touches[0]; 
     touch.x = t.clientX; 
     touch.y = t.clientY; 
    }; 

    itemWrap[0].ontouchmove = function(e) { 

     // only deal with one finger 
     if (e.touches.length == 1 && !itemWrap.is(":animated")) {   
      var t = e.touches[0], 
       deltaX = touch.x - t.clientX, 
       deltaY = touch.y - t.clientY; 
      if(deltaX > 200 || deltaX < -200) { // new line 
       self[vertical && deltaY > 0 || !vertical && deltaX > 0 ? 'next' : 'prev']();  
      } // new line 
      e.preventDefault(); 
     } 
    }; 
} 

調整200至然而到目前爲止,您希望鄉親要拖他們的手指才切換到下滑動。同樣,如果你想控制的新代碼垂直滾動變化DELTAX到DELTAY:

if(deltaY > 200 || deltaY < -200) { // new line 
    self[vertical && deltaY > 0 || !vertical && deltaX > 0 ? 'next' : 'prev']();  
} // new line 

如果你正在使用jQuery工具的最小化版本,則可以使用此代碼:

​​3210