codrops / SlitSlider

A responsive slideshow with a twist: the idea is to slice open the current slide when navigating to the next or previous one. Using jQuery and CSS animations we can create unique slide transitions for the content elements.
459 stars 135 forks source link

onAfterChange parameter returns the previous element #37

Open matthiasburger opened 6 years ago

matthiasburger commented 6 years ago

I'm trying to get the actual chosen element when switching the slider from one to the next element.

this is my onAfterChange. I thought, when I call this, slide returns the new element, but it always returns the old one.

This is my Page-object:

var Page = (function () {

var $navArrows = $('#nav-arrows'),
    $nav = $('#nav-dots > span'),
slitslider = $('#slider').slitslider({
    onBeforeChange: function (slide, pos) {

        $nav.removeClass('nav-dot-current');
        $nav.eq(pos).addClass('nav-dot-current');

    },
    onAfterChange: function (slide, pos) {
        var id = $(slide).attr('id');
        alert(id);
        return true;
    }
}),

but when I want to switch to the next one, the alert always prints the id of the previous element instead of the current one. Funny is, when I switch back to the previous element, the alert prints the correct id. The pos-parameter is always correct.

Any idea?