【问题标题】:Continuously slide in owl carousel, without delay stop and should immediate stop on hover连续滑入猫头鹰转盘,无延迟停止,悬停应立即停止
【发布时间】:2023-12-26 18:17:01
【问题描述】:

嗨,我正在尝试使用 owl carousel 连续滑动,而不会延迟单张幻灯片,并且幻灯片应在悬停时立即停止。任何人都可以帮帮我..

【问题讨论】:

    标签: javascript plugins jquery-plugins owl-carousel


    【解决方案1】:

    查看文档owl-carosuel 你只需要使用 stopOnHover

    $("#owl-demo").owlCarousel({
          autoPlay: 3000, //Set AutoPlay to 3 seconds
          stopOnHover: true,
          items : 4,
          itemsDesktop : [1199,3],
          itemsDesktopSmall : [979,3]
      });
    

    【讨论】:

      【解决方案2】:

      您需要将 stopOnHover 选项添加到您的 js 文件中。根据 owl carosuel 的文档,如果我们想在悬停它时停止滑动,我们可以设置 stopOnHover: true; 为了让幻灯片顺利滑动,您必须使用 autoplayTimeout 选项,它可以帮助我们以毫秒为单位设置时间。所以你的代码应该是这样的:

      $(document).ready(function(){
       $('.owl-carousel').owlCarousel({
        loop: true,
        autoplay: true,
        autoplayTimeout: 2000, // 2 sec you can change it as per you choice.(time between tow slide changes).
        stopOnHover: true, // To stop sliding on hover.
        responsive: {
              0: {
                  items: 1
                 },
              600: {
                  items: 2
                 },
              1190: {
                  items: 3
                  }
                 }             
       });
      });
      
      
      

      【讨论】: