ryanflorence / SlideShow

Extensible mid-level MooTools slideshow class that manages transitions of elements that share the same space, typically for slideshows, tabs, and galleries.
http://ryanflorence.com/slideshow
104 stars 22 forks source link

fireEvent('show') suggestion #1

Closed mediamedics closed 13 years ago

mediamedics commented 14 years ago

This is not a bug, merely a suggestion. (very nice class by the way) In the SlideShow.js 'show' method the 'show' event is fired before the 'current' slide is set. I have a case where it would help if this fireEvent call is done at the end of this method. This is very helpful when you want to add slide buttons which would call the 'show' method onclick and call an arbitrary slide to show. (one which would not be the next) I just followed your suggestions in the documentation on how to add these buttons. When you would use the onShow event to add and remove classes to and from the buttons to indicate the current slide being shown you can't use this.current or this.nextSlide() to retrieve the slide which is being shown from the click event. (current is still the previous one and nextSlide() just returns the next in the regular order). Also the show event doesn't send the slide as an argument. This can all very easily be fixed by just firing the 'show' event after the new current is set in the show method. Then you can use the this.current property in the onShow event to retrieve the related button and change its appearance to indicate which slide is 'active' after the click. The same code will then automatically do this while the slideshow is playing and progressing to the next slide.
I hope you will consider this suggestion, gr, Vic

ryanflorence commented 13 years ago

I had this same problem several months ago as well.

Note the arguments passed to the new show and showComplete:

mySlideShow.addEvent('show', function(slideData){
  slideData.next.element; // the actual DOM element
  slideData.next.index; // the index of the element in the slideshow
  slideData.previous.element;
  slideData.prevoius.index;
});