angular2-useful-swiper: not working Autoplay swiper

I’d like to add autoplay swiper. added code is like this.

config: SwiperOptions = {
    pagination: '.swiper-pagination',
    paginationClickable: true,
    spaceBetween: 30,
    autoplay: 3000,
    loop: true
  };

But it doesn’t work to autoplay. please review it and let me know.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 3
  • Comments: 25

Most upvoted comments

Please make sure to import {Autoplay} module and make the swiper use it

import Swiper, { Autoplay} from ‘swiper’; Swiper.use([Autoplay]);

Hi guys, the implmentation of autoplay is wrong. @shavin47 @ninjadev1030

The best way is:

autoplay: { delay: 3000, }, For more options see also: http://idangero.us/swiper/api/

Please make sure to import {Autoplay} module and make the swiper use it

import Swiper, { Autoplay} from ‘swiper’; Swiper.use([Autoplay]);

it’s working

.angular-cli.json “script”:[ “…/node_modules/jquery/dist/jquery.min.js”, ]

implement the module in the parameter options like so modules: [Autoplay]:

const swiper = new Swiper(".gallery", {
    modules: [Autoplay],
    loop: true,
    autoplay: {
        delay: 3000,
        }
});

hope helps!

Thanks, yes, it is working in Agular 9.

I couldn’t get the AutoComplete module to work at all, so ended up implementing this myself, like so:

Pass the swiper instance to the component:

<swiper (swiper)="setSwiperInstance($event)">

Then in my component:

setSwiperInstance(swiper: Swiper) {
  setInterval(() => {
    swiper.slideNext();
  }, 3000);
}

Bit of a hack but it works 😃