Closed simonlagneaux closed 12 years ago
Off the top of my head I can't think why it would fire the same number of times as the number of slides however I know both the beforeAnimate and afterAnimate callbacks will fire once each on init as it jumps to the first slide (or the options.startAt slide) without preventing these callbacks which probably isn't desired. mmm and they're likely called again if the continuous extension is included to take into account the cloned items... I'll take a closer look into this when I get some time.
Great, thanks !
I've changed how this works in 0.8.6 - it'll now still be called on page load (because goToPage is fired on load) however rather than simply ignoring the callback when animate is set to false I'm now passing in a flag to determine whether the transition was animated or not. This should help if you're transitioning something in (a caption for example) before or after animate so you can determine whether to run the callback - does this help in your situation? (also, just to note, if you decide to upgrade to 0.8.6 there have been a number of option changes so you might need to read through the docs again).
So you might do something like this:
$('#carousel').carousel({
after: function (e, data) {
if (data.animate) {
// run some code
}
}
});
The afterAnimate and beforeAnimate functions are fired mulitple times (same as the number of slides) when page loads.