Jump to content
GreenSock

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

Trouble with calling function into timeline

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thats perfect, i had missed to call the function, inside another anoter one, thanks again i am really apreciated it . 🤗

  • Like 1

Share this post


Link to post
Share on other sites

No problem! Happy tweening. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×