Jump to content
Search Community

onStart of timeline can i pass a function which has return parameter

Fahim test
Moderator Tag

Go to solution Solved by Rodrigo,

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 Team,

 

onStart of timeline can i pass a function which returns an array of divs which will be tweened.

i see some good examples of calling onStart function with parameters but don't know how to handle the return and loop it in timeline so that each can be tweened. 

I don't know if i am making sense at all or not. i hope i haven't asked too many silly questions.

 

 

 

See the Pen aKrhj by osricmacon (@osricmacon) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

There are no silly questions just silly answers.

 

I believe is not possible to add a onStart callback on a Tween/Timeline that will return the elements the timeline should animate, without falling in a sort of complex scenario. Sure you start the timeline, execute the onStart callback and that callback returns a series of elements (tiles in this case) that are animated in the same timeline. But where exactly you'll be adding the animations in the timeline?, once the timeline starts and the onStart callbacks is executed, the timeline's playhead is no longer at 0 seconds, is actually moving forward. So should you add the instances after the code is executed, but how much time that is?. If you add the instances at the end of the timeline, but there's nothing else in the timeline, the first animation would look a bit out of sync because the timeline will adjust the instance to the current time in the timeline. See what I mean?.

 

Some time ago another user asked about splitting images into a grid and Jamie came up with this great example:

 

See the Pen ?editors=001 by jamiejefferson (@jamiejefferson) on CodePen

 

Perhaps you could try  a simpler approach to this, where you create the grid and then loop through the grid elements and add them to a timeline. Now if you need some sort of timing mechanism to execute your function and then the timeline, you can use a delayedCall() instance for that.

 

Rodrigo.

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