Jump to content
Search Community

Help with TimelineMax.staggerFrom with onCompleteAll

candybanners 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

Hi guys,

 

I'm having problems implementing the onCompleteAll function within my TimelineMax animation. My code looks like below

 

var tl = new TimelineMax(); 
tl
.from('.text1',0.5,{opacity:0, y:'+=10'})
.to('.text1',0.5,{opacity:0},'+=3')
.from('.text2',0.5,{opacity:0, y:'+=10'})
.staggerFrom('.footer',0.5, {opacity:0, y:'+=10'},0.2, addBirdEvent)
function addBirdEvent(){
console.log('footer animations done')
}

Problems are:

  • The stagger animation runs immediately. I'm expecting it to run after the previous animation ends.
  • The addBirdEvent (which is my onCompleteAll function) also runs immediately.
  • I also tried using onCompleteAll: addBirdEvent but theres an error saying 'missing ) after argument list.'

What do you think is wrong with my syntax?

 

Thanks in advance!

 

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The problem is that your onCompleteAll is where the position parameter should be.

 

.staggerFrom( targets:Array, duration:Number, vars:Object, stagger:Number, position:*, onCompleteAll:Function, onCompleteAllParams:Array, onCompleteScope:* ) : *

 

 

 

onComplete all is the 6th parameter.

.staggerFrom('.footer',0.5, {opacity:0, y:'+=10'},0.2, "+=0", addBirdEvent)

Easy mistake to make if you are used to TweenMax.staggerFrom()

 

 

Here is a demo using TimelineMax.staggerTo() 

http://codepen.io/GreenSock/pen/XmNRmq?editors=101

  • Like 2
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...