bob
bob

Reputation: 933

Swiper.js: delay parameter ignored

I'm creating a simple slideshow using swiper.js.

My config looks like this:

var mySwiper = new Swiper( '#swiper-container',
                               {
                                   autoplay: {
                                       delay : 400000
                                   },
                                   loop: true,
                                   speed: 2800,
                                   grabCursor : true

                               }
                             );

This pretty much works... except that the 'delay' parameter gets ignored.

I've also tried putting the 'delay' parameter outside of the autoplay object, like this:

v

ar mySwiper = new Swiper( '#swiper-container',
                               {
                                   autoplay: true,
                                   delay: 4000,
                                   loop: true,
                                   speed: 2800,
                                   grabCursor : true

                               }
                             )

;

This doesn't help. The delay value is ignored.

What could be happening here?

Upvotes: 5

Views: 12501

Answers (5)

CrowScript
CrowScript

Reputation: 155

Don't forget to import it.

import Swiper, {Navigation, Pagination, Autoplay} from 'swiper';

Upvotes: 0

Mavis Huang
Mavis Huang

Reputation: 1

this is useful information, and it works. thank you. for 3.x.x version. I add below like this.

autoplay : 4000,
speed: 300,

Upvotes: 0

Jbennie
Jbennie

Reputation: 21

autoplay : 4000 // works for 3.x.x version

autoplay : false or { delay:4000, ....} // works for 4.x.x versions

full details are on github docs

Upvotes: 2

Alice Arkalykova
Alice Arkalykova

Reputation: 162

Autoplay takes a boolean value, that's not an option Instead, I've found a working option. It's pretty clear in documentation

So you just have to add this parameter to your div class="swiper-slide" and it'll work:

data-swiper-autoplay="2000"

Upvotes: 1

JoeMecPak
JoeMecPak

Reputation: 648

The way you wrote it should work, according to Swiper official documentation. But you can also try to set the delay as the autoplay value, it should do the trick:

var mySwiper = new Swiper( '#swiper-container', {
    autoplay: 4000,
    loop: true,
    speed: 2800,
    grabCursor : true
});

The code above has been tested with the current Swiper version (4.1.0).

Upvotes: 6

Related Questions