Jump to content
Search Community

function call assistance

Joostan 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

Good afternoon,

imagine a number of elements that need to be tweened onto 'stage' and off 'stage' depending on the user selection.

 

  • How on earth do make a call to a timeline in a function from a number of buttons?
  • Maybe there is a better approach to my attempt in the pen line 65.

 

Thank you for taking the time to look at this post.

 

See the Pen qoxRYv by Joostan-33 (@Joostan-33) on CodePen

 

 

 

See the Pen qoxRYv by Joostan-33 (@Joostan-33) on CodePen

Link to comment
Share on other sites

I imagine this is what you're looking for: 

See the Pen jzZBeX?editors=0010 by GreenSock (@GreenSock) on CodePen

Right? 

 

There are actually a lot of ways you could handle this - I just provided one. I attached all your animations to an "animations" object with properties named according to your functions. That makes it relatively easy to access them and call them dynamically, like animations[currScene + "out"](). 

 

I also needed to fix the way the click() events were assigned, and the logic in that function. 

 

Hopefully this gets you going in the right direction, but let us know if you need anything else. 

 

Happy tweening!

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

16 minutes ago, Joostan said:

I really need to learn more javascript, i find it so fiddly!

 

Nah, after a while it'll make sense. Hang in there - we all went through that season where we felt like we're running in muck trying to get anything done in JS. It'll get better. Hang around these forums and it might help accelerate the process a bit. Lots of smart people around here.  

 

Thanks for being a Club GreenSock member.

 

Good luck with your project. 

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