Jump to content
Search Community

Problems with negative margin left tween

sebak 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

Hello,

 

I've found a weird problem with gsap.

Basically I have a page similar to:

 

 

<div id="viewport" style="overflow:hidden;">
<div id="scroller" style="width:9000px;">
<ul id="list"><li style="float:left;"></li><li style="float:left;"></li> ... </ul>
</div>
</div>
 

I have some code that calculates a number and the lists margin-left css property should change accordingly, so something like:

 

 

 

TweenLite.to("#list", 0.3, {marginLeft:'+='+$scroll+'px'});
 

Where $scroll is calculated, and can sometimes be negative.

However, when it's negative gsap seems to multiplies the value by 10...

So when the $scroll value is -660, the margin left adjusts -6600.

I currently do a check and if it's negative I use '-=' and the absolute value.

Link to comment
Share on other sites

Ah, yes, I see exactly what you're talking about. It actually doesn't multiply by 10 (although it acts that way in your scenario) - since it was expecting a "+=" or "-=" prefix and yours had "+=-", the parsing code was thrown off a bit and it was leaving the last part of the number on the suffix. So, for example, if you had "+=-15px", it would use "5px" as the suffix instead of just "px". And if you had "-=20px", the suffix would be "0px". I've remedied that issue for 1.8.5 which should get pushed out in the next few days. Thanks for pointing this out, and sorry about any hassle(s). 

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