Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Catalin R.

How to add tweens and functions to a timelineMax at the same time?

Recommended Posts

Hi,

What is the right code to add tweens and functions to a timelineMax at the same time?

Thanks!

Link to comment
Share on other sites

If I'm understanding what you're asking, it's as simple as

 

var tl = new TimelineMax();

tl.add( function(){ console.log('This function is running at the same time as the tween below is beginning'); } )
  .to( '#someElement' , 1 , { x: 100 } );

 

  • Like 4
Link to comment
Share on other sites

in addition to what Shaun advised, if you need to add them at a specific time, use the position parameter

var tl = new TimelineMax();

tl.to("#someElement", 1, {opacity:1})



//call function and start tween at time of 2 seconds

tl.add( function(){ console.log('This function is running at the same time as the tween below is beginning'); }, 2 )
  .to( '#someElement' , 1 , { x: 100 }, 2 );

 

 

also if you are calling your function with call(), that also has a position parameter: https://greensock.com/position-parameter

 

The position parameter can be an absolute time, relative time, or label.

  • Like 4
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.
×