richardscarrott / jquery-ui-carousel

jQuery RS Carousel is a responsive and touch-enabled carousel written on top of jQuery and the jQuery UI Widget Factory providing a full and familiar API in less than 2.6kB minified and gzipped.
http://richardscarrott.github.io/jquery-ui-carousel/
192 stars 56 forks source link

_slide is overriding carouselafter.originalEvent when translate3d is set #62

Closed ghost closed 11 years ago

ghost commented 11 years ago

STEPS TO REPLICATE:

$(':rs-carousel').on('carouselafter', myHandler);

EXPECTED RESULTS:

ACTUAL RESULTS:

DISCUSSION: This appears to be related to this code snippet (Line 542):

                    // Here e is the original 'carousel:next' event
                    .on(transitionEndEvent.join(' '), function (e) {
                        self.element.removeClass(fullName + '-transition');
                        if (!silent) {
                            // Now e is the incoming 'transitionend' event, instead of the original event
                            self._trigger('after', e, self._getEventData());
                        }
                    })

It appears that you are overriding the original event object e by using it as the parameter for your anonymous function. Removing the e parameter, or renaming it to ev, fixes the issue.

However, I'm unsure of your intent for this block. Are you intending to propagate the transitionend event, or override it with the carousel:next as we expect?

richardscarrott commented 11 years ago

Good catch and thanks for the detailed report. Your expected outcome is as I had intended it so it appears I've accidentally defined e in the the transitionend callback's scope. If you want to send a pull request with the e removed from that callback then I'll merge it in otherwise I'll look to make the change as soon as I get a chance.