Owl Carousel Won't Autoplay

后端 未结 15 1203
失恋的感觉
失恋的感觉 2020-12-01 18:06

I\'m using the Owl Carousel on my site. According to their documentation, this piece of JavaScript should work:



        
相关标签:
15条回答
  • 2020-12-01 18:15

    Changing autoplay to autoPlay alone did not work for me. What did the trick was to add autoplaySpeed and autoplayTimeout properties and set them to the same value, like this:

    $(document).ready(function(){
        var owl = $(".owl-carousel");
        owl.owlCarousel({
            items: 1,
            autoplay: true,
            autoPlaySpeed: 5000,
            autoPlayTimeout: 5000,
            autoplayHoverPause: true
        });
    });
    

    Here's a working demo: JS Bin

    More info about this can be found here: https://github.com/smashingboxes/OwlCarousel2/issues/234

    0 讨论(0)
  • 2020-12-01 18:16

    add this

    owl.trigger('owl.play',6000);
    
    0 讨论(0)
  • 2020-12-01 18:17

    Owl Carousel version matters a lot, as of now (2nd Aug 2020) the version is 2.3.4 and the right options for autoplay are:

    $(".owl-carousel").owlCarousel({
        autoplay : true,
        autoplayTimeout: 3000,//Autoplay interval timeout.
        loop:true,//Infinity loop. Duplicate last and first items to get loop illusion.
        items:1 //The number of items you want to see on the screen.
    });
    

    Read more Owl configurations

    0 讨论(0)
  • 2020-12-01 18:19

    This code should work for you

    $("#intro").owlCarousel ({
    
            slideSpeed : 800,
            autoPlay: 6000,
            items : 1,
            stopOnHover : true,
            itemsDesktop : [1199,1],
            itemsDesktopSmall : [979,1],
            itemsTablet :   [768,1],
          });
    
    0 讨论(0)
  • 2020-12-01 18:19

    Just a Typing Error,

    <script>
    $("#intro").owlCarousel({
    
    // Most important owl features
    
    //Autoplay
    autoPlay : 5000,
    stopOnHover : false
    )} ----- TYPO
    </script>
    

    It should be-

    <script>
    $("#intro").owlCarousel({
    
    // Most important owl features
    
    //Autoplay
    autoPlay : 5000,
    stopOnHover : false
    }) ----- Correct
    </script>
    
    0 讨论(0)
  • 2020-12-01 18:22

    Yes, its a typing error.

    Write

    autoPlay

    not

    autoplay

    The autoplay-plugin code defines the variable as "autoPlay".

    0 讨论(0)
提交回复
热议问题