Jump to content
Search Community

Update vars of a Tween which already added to a timeline

RolandSoos 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

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

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