2

Flickity has event binding. Is there an event for when the next or previous slide is moved to? For example the settle event is fired after a slide settles. This does do what I need but the problem here is it also fires if Flickity settles on the same slide, this would happen if you swiped but didn't swipe enough and Flickity settles back where it was. The cellSelect demo appears to do much the same thing.

In my mind something like this perhaps explains what I'm trying to achieve:

$carousel.on( 'nextSlideReached', function() {
   console.log( 'Flickity has settled on the next slide' );
});

1 Answers1

1

Using the settle event we can check if we've settled at a new slide or not:

var selectedIndex = flkty.selectedIndex;

$carousel.on( 'settle', function() {
  if ( flkty.selectedIndex !== selectedIndex ) {

    console.log('settled at new cell', flkty.selectedIndex);
    selectedIndex = flkty.selectedIndex;

    // do stuff

  }
});
  • This code should update the selectedIndex everytime the 'settle' is called, right? I have the same code and keep getting `0` for selectedIndex. – nclsvh May 25 '16 at 11:11
  • @NicolasV did you define $carousel..? + you now need to use the flickity [namespace](http://flickity.metafizzy.co/extras.html#compatible-changes) aka. settle.flickity – honk31 Jul 20 '16 at 12:07