Jump to content
GreenSock

RolandSoos

Update vars of a Tween which already added to a timeline

Recommended Posts

As I know GSAP can't handle percentage values for x and y. Percentage values can help us to make relative animations (relative to the element's width or height) combined with responsive design. 

 

Here is a codepen which shows the problem:

See the Pen fszAh by anon (@anon) on CodePen

 

Steps:

  1. Load the codepen
  2. click on the red box
  3. watch the animation, it moves horizontally 100% relative to the width of the current box
  4. Resize your window
  5. Click on the box again
  6. The tween doesn't get updated, so it moves horizontally with the old width

Is there a way to "fix" this?

 

I would like to prevent the browser from the recreation of the tweens and timelines every time the browser resizes.

Link to comment
Share on other sites

updateTo is not designed to work with plugin values (CSS is controlled by the CSSPlugin) so it's not going to be effective here.

 

GSAP transforms are implemented with transformation matrices so percentages aren't available, but left and top still work perfectly with percentages. Is

See the Pen bswzx?editors=001 by anon (@anon) on CodePen

working as expected for you?

  • Like 2
Link to comment
Share on other sites

I'm using the position values (left and top for other purpose and I don't want to change them with the animation).

 

I just wanted to update my tweens every time on windows resize, but it seems like it is currently not possible. Am I right?

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