Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Roman Kovalev

How to update value in tween when reversed?

Recommended Posts

Hey, there! 
Is there a way to update the value inside tween when getting the animation reversed? For now I need some kind of fake preload animation, before modal window loads, so I'm using delay parameter with a variable value . But when I'm closing modal window (by clicking on a background layer), animation reversing but considering that delay. Is there a way to change that variable value on reverse?

See the Pen yzLqXG by NeedHate (@NeedHate) on CodePen

Link to comment
Share on other sites

Thanks for the demo. 

The short answer is no, there isn't an easy (practical) way to just remove the delay from a tween in a timeline when it is reversed. Yes, you could find the tween in the timeline, remove its delay and then shift the following tweens around, but then when you want to move forward again you would have to add the delay back in and move the tweens that follow. It can get messy.

 

Once you say "i want this animation to something different in reverse" you step beyond what reverse is supposed to do. You need a different animation.

My suggestion is to have separate functions for your open and close animations. When you call those functions you create the necessary timelines.

This allows you to have much more flexibility

 

Something like:

See the Pen jGEOVx?editors=0011 by GreenSock (@GreenSock) on CodePen

 

 

 

 

 

  • Like 4
Link to comment
Share on other sites

Ok. Cool! Thanks for a suggestion. I appreciate that and will follow your advice.

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