Jump to content
Search Community

Trouble with calling function into timeline

Kovsky 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 Greensockers,

First of all i want to thank you everyone. This forum and this community have been very helpfull from the begining. 

Now here is the problem ^^

Im trying to do animations in a React (Gatsby) website. I have a slider section where i want to change lot of stuff on my site when i switch from a slide to another (color menu, color buttons, color title...) So i use  React Redux with state to do this and call my action to change my color.
Everything is working, the function is called, but at the begining of the timeline, before all the previous one. I think i have syntax a problem, i tried to separate functions and parameters in the call function but without success.

Thank you for your help.

 

See the Pen RwwoQja by Kovsky (@Kovsky) on CodePen

Link to comment
Share on other sites

Yeah, it's just a JavaScript thing. 

 

When you this.props.dispatch(setColor('#1b00ff')), that runs it immediately because the () act as an instruction to invoke the function. You just need to wrap it in a function:

 

.call(function() {
  this.props.dispatch(setColor('#1b00ff'))
}, null, this, '+=2')

You were missing the params parameter too. https://greensock.com/docs/v2/TimelineLite/call()

 

Does that clear things up? 

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