Jump to content


relative values issue

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

Hello all.


So I've been using relative values in my tweens for quite a large project and I've noticed that with the latest update, the relative values are interpreted as absolute values when declared without an equals sign.  I've been doing y:"-50" for animating an objects relative position in the y-axis instead of y:"-=50", for example,  causing the object to animate off the top of the screen.


There are a lot of these scattered across many files, so while updating them manually wouldn't be out of the question, it would be an immense pain to do so.  


I was wondering, if it isn't too much of a hassle, if the library could have backwards compatibility for the old way of declaring relative values.



Link to comment
Share on other sites

Hi Alec,


Just to be clear, which version of GSAP are you using? AS3, AS2, or JS?


I ask, because you posted in the JS forum, but as far as I recall, the = sign was always required for relative tweens in the JS port.



Link to comment
Share on other sites

You are talking about the JS version, right? In the JS flavor, the proper way to do relative values has always been to add "+=" or "-=" prefixes. There was never a time when casting as a string was prescribed (without the +=/-= prefix). In the AS3/AS2 version, however, we allowed casting as a string purely for backwards compatibility since that's how it was done in old versions, but we tried to make it pretty clear in the docs that the proper way was to use +=/-= prefixes. That's not possible with JS, though, because many values MUST be strings, like if you want to tween a DOM object's css to width:"70%". See how that would be impossible to define as a number (since there's a % suffix)? In other words, how could the engine distinguish between a relative and absolute value in that scenario without something like "+=" or "-="?

Link to comment
Share on other sites

Yes, I'm using the JS version.  


I only recently find out about the "-=/+=" way of doing it because of this issue.  Although, the version of the library I'm using hasn't been updated in a while (it's beta 1.65 version from 6 months ago).  I think the most sensible solution is to go back and update all my previous stuff and the library.


Thanks for your input, guys.

Link to comment
Share on other sites

If you use a lot of the convenience methods of TimelineLite/Max, be sure to read about this important change:






This change applies to how relative values are declared when referring to a tween's position inside a TimelineLite/Max. I thought perhaps, this is what you were referring to, but you were pretty clear in your initial post that you had problems with setting target values of tweens like : y:"-=50". 


There were a number of enhancements offered in 1.8.0 http://www.greensock.com/update-2013-01/ but nothing that should break previous code.



Let us know if you have any other problems with the upgrade. I'm sure we can help you through any other issues. The upgrade might be inconvenient, but I'm confident that it will be worthwhile. We've introduced a ton of features, performance enhancements and found new ways of handling some very strange browser bugs. 

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.