2013-01-04 75 views

回答

0

我解決了它。解決方案並不漂亮,但有效。而且,代碼片段應該移到單獨的代碼文件中。 TODO:重構。

1)「scrollableArea」div應該有屬性tabindex。 2)在插件代碼文件中,以下代碼語句應添加到_create函數中。應該重構,因爲它是目前相當距離鼠標滾輪事件處理

r.data("scrollableArea").keydown(function (e) { 

      var arrow = { left: 37, up: 38, right: 39, down: 40 }; 
      var i,s,u; 

      switch (e.keyCode || e.which) { 

       case arrow.left: 
        i = 1; 
        s = 0; 
        u = 1; 
        break; 

       case arrow.right: 
        i = -1; 
        s = 0; 
        u = -1; 
        break; 
      } 

       if (r.data("enabled") && n.mousewheelScrolling.length > 0) { 
        var a; 
        n.mousewheelScrolling === "vertical" && u !== 0 ? (t.stopAutoScrolling(), e.preventDefault(), a = Math.round(n.mousewheelScrollingStep * u * -1), t.move(a)) : 
        n.mousewheelScrolling === "horizontal" && s !== 0 ? (t.stopAutoScrolling(), e.preventDefault(), a = Math.round(n.mousewheelScrollingStep * s * -1), t.move(a)) : 
         n.mousewheelScrolling === "allDirections" && (t.stopAutoScrolling(), e.preventDefault(), a = Math.round(n.mousewheelScrollingStep * i * -1), t.move(a)); 
       } 
      }), 
+0

答案的目的是真正回答這個問題複製。問題不在於解決問題的地方。所以,相反,從你的問題中刪除答案,並在這個答案中寫下來。 – j0k