簡體   English   中英

我需要 slider 使用鼠標滾輪

[英]I need to slider work with mouse wheel

請參閱此 URL: http://whipwap.co.uk/shopsense/slider_example/slider_test.html

代碼是:

$(文檔).ready(函數(){

$("#content-slider").slider({ mousewheel:true, animate: true, change: handleSliderChange, slide: handleSliderSlide }); });

現在我想用鼠標滾輪滑動。我該怎么做。

尋求您的支持。

謝謝,

迪帕克

在您的$(document).read()添加以下代碼:

      $("#content-slider").bind('mousewheel', function(event, delta) {
          var newValue = $(this).slider("value");
          var step = $(this).slider("option", "step");
          if (delta > 0)
              newValue += step;
          else
              newValue -= step;
          $(this).slider("value", newValue);
      });

您可能希望減少 animation 長度或清除handleSliderChange()中的隊列,因為使用鼠標滾輪時滑動會變得抖動。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM