Jump to content
Search Community

Arrg. TimelineMax onComplete being fired more than once

peterPotter test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I was about to launch my site when I realize some inconsistent behavior with the onComplete callback. It works fine (i.e., fire the onComplete event just once) about 90% of the times in Chrome, and it is even more inconsistent on Safari and Firefox. For the latter two browsers, onComplete is being fired more than once often, and sometimes twice, and sometimes thrice, and sometimes once. 


if (this.tl) {
this.tl.invalidate();
}

this.tl = new TimelineMax({delay: 0});

this.tl.staggerTo(arrayOfElements, 0.55, {
onComplete: function () {
// The Console is logging this more than once sometimes, and sometimes just once, depending on the browser
console.log ("staggerTo Complete");
},
autoAlpha: 0,
y: "50",
ease: Expo.easeOut
}, 0.06, "+=0.08");
Link to comment
Share on other sites

I would be very interested in seeing a demo that shows the same code working differently between browsers.

The way your code is set up is that "staggerTo complete" will fire after each tween in the stagger completes.

 

Here is a demo that shows how to use the onCompleteAll parameter in a staggerTo.

 

http://codepen.io/GreenSock/pen/bzopa?editors=001

 

Notice how the message "all tweens are done" only appears once.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...