2017-06-15 70 views
0

我在我的網站上使用引導輪播滑塊。我想幻燈片來改變mouseScroll.how我可以做this.this代碼工作正常,但我想改變mouseScroll 幻燈片,這是我的代碼滑動鼠標滾動更改

 <script> 
    $(document).ready(function() { 
     $("#product_slider").owlCarousel({ 
     rtl:true, 
     loop:true,               
     margin:4, 
     autoplay:false, 
     autoplayTimeout:10000, 
     autoplayHoverPause:true, 
     lazyLoad : true, 
     pagination:false, 
     nav:true, 
      dots: false, 
     navText:false , 
     responsive:{ 
     0:{ 
      items:1 
     }, 
     500:{ 
      items:1 
     }, 
     768:{ 
      items:4 
     }, 
     1200:{ 
      items:5 

     } 
     } 
     }); 

    }); 
</script> 

回答

0

當你滾動鼠標滾輪這將使轉盤變化超過它。我認爲在鼠標移過旋轉木馬時防止整個頁面滾動是明智的做法,但我沒有花時間在這裏做。
小提琴https://jsfiddle.net/mikeferrari/z34m1wbo/

// select the carousel container 
var myelement = document.getElementById("myCarousel"); 

// this function is called every time the mouse wheel is scrolled 
function makeItSo() { 
    // this is where you tell it to go to the next slide 
    $('.carousel').carousel('next') 
} 

myelement.addEventListener('wheel', function(e) {  
    makeItSo(); 
}); 


// start your carousel on page load 
$('.carousel').carousel({ 
    interval: 2000 
}) 
+0

,但它顯示了一個錯誤「遺漏的類型錯誤:$(...)旋轉木馬是不是一個函數」 – user94

+1

你改變它來滿足你的代碼?您需要用示例代碼中的myCarousel替換.owlCarousel –