JoshDSommer / nativescript-slides

A NativeScript plugin that is for Intro Tutorials, Image Carousels or any other slide functionality
Other
70 stars 32 forks source link

automatically rotate slides #79

Closed cindy-m closed 7 years ago

cindy-m commented 7 years ago

I implemented the slider with a few pictures. At the moment the pictures are first static until the user decides to slide them. So I was wondering it it is possible to let the slides rotate automatically (a sort of slideShow)??

JoshDSommer commented 7 years ago

Hi @cindy-m, what you could do is set an interval to call the .next() every few seconds.

cindy-m commented 7 years ago

you mean something like this: ngAfterViewInit() { var SlidesXml = this.slides.nativeElement; // SlidesXml.constructView(); setInterval(() => { SlidesXml.nextSlide(); }, 100); }

?? I am really new to nativescript (in combination with angular2), so I was wondering what the right way is to do set the interval

cindy-m commented 7 years ago

Got it working :D Thanks a lot :D :D

JoshDSommer commented 7 years ago

Awesome! 💃

matheusabr commented 7 years ago

If anyone needs in a plain JS, just follow this code:

slideContainer = page.getViewById('slideContainer')
  setInterval(function () {
    slideContainer.nextSlide()
  }, 4000)