Skip to content

Event 'before.lory.slide' reports wrong 'nextSlide' #520

Open
@UTurista

Description

@UTurista

The slides reported by the before.lory.slide event are wrong when the method slideTo( k ) is used.

This because the value nextSlide is defined by direction and by incrementing the current index;

var nextSlide = direction ? index + 1 : index - 1;

dispatchSliderEvent('before', 'slide', {
   index: index,
   nextSlide: nextSlide
});

The following example:

var simple =  lory(target, {
    infinite: 1,
    slidesToScroll: 1
});

// Listeners
body.addEventListener('before.lory.slide', function(e){
  console.log("before(" + e.detail.index + " => " + e.detail.nextSlide + ")");
});
body.addEventListener('after.lory.slide', function(e){
  console.log("after(" + e.detail.currentSlide + ")");
});

simple.slideTo(3);
simple.slideTo(1);

will return the follow output

before(1 => 0)
after(4)
before(4 => 3)
after(2)

instead of

before(1 => 4)
after(4)
before(4 => 2)
after(2)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions