Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Reincha

Added function stops further timeline execution

Recommended Posts

Hi!

Please see my codepen example.

Why the timeline doesn't execute "to" command after function call?

(the commented out variation of adding works, but is it correct?)

I'm new to Js & GSAP so there may be issues with my code as I couldn't find similar issues on the forum.

Thanks in advance!

See the Pen RvXzjV by reincha (@reincha) on CodePen

Link to comment
Share on other sites

Hi @Reincha,

 

Yes, the commented out version is correct! If you place a call to a function directly into the add() parameter, it's called at runtime. When you pass an anonymous function as the parameter, it's called at that position in the timeline.

 

Have a look here to see that even if you .add( someFunction() ) to the very end of the timeline, it's called immediately.

 

 

See the Pen pGMMZy by sgorneau (@sgorneau) on CodePen

 

 

Hope this helps!

 

Link to comment
Share on other sites

Thanks, @Shaun Gorneau ! What is the proper way to make this next "to " wait until function animation ends? Now, If I don't put any delay parameter to ".to" they start together. I don't want to put manual delay as  duration of the animation in that function can change in the future.

Link to comment
Share on other sites

Looking further down ... it looks like you're doing all the interpolating way outside of GSAP ... so that is all happening without a Timeline's awareness. And following to(), from(), etc is just going to be called.  (I'm on my first cup of coffee ... so I could be wrong)

 

In regard to tweening the SVG shape and position ... you should probably look at MorphSVG in combination with simple tween properties (y in this example).

 

https://greensock.com/morphSVG

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