Jump to content
Search Community

wrong top value in FF (correct in chrome)

Sumit 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

Hi there,

 

i built a JSFiddle to show the issue:

 

http://jsfiddle.net/kDAqE/

 

you'll see - firefox doesn't animate correctly from -30 to 0px. Instead the animation tweens to some random number - 94px in this case. Maybe it starts at the elements current position  calculated by the browser, forgets the CSS (top: -30px) and adds 30px. However it should start at the elements current CSS position which is -30px and add 30px.

Animation is correct in Chrome.

Link to comment
Share on other sites

Thanks for the fiddle, it made it very easy to figure this one out.

 

You'll find that this problem is not directly related to anything GSAP is doing, but to how the 2 browser's are rendering your elements with the CSS you've used.

 

If you remove the Tween from your fiddle and replace it with

alert($('.inner').css('top'));

(here) you'll see that Chrome and Firefox are reporting different values for top (Chrome: -30px, Firefox: 64px). While GSAP might not be animating as you would have expected here, it is still actually working correctly by tweening top to its current value + 30.

 

It looks like Firefox is applying the margin: auto; to the position values instead of the actual margins, so in Firefox .inner effectively has margin: 0 while the top value is adjusted to its on-screen position.

 

Here's an adjustment to the page that work's fine in both browsers: http://jsfiddle.net/kDAqE/2/

  • Like 1
Link to comment
Share on other sites

Thank you for pointing me to the browser differences.

I would still argue that GSAP is doing something wrong here.

 

Let's say the offset between inner and outer DIV is 50px. And now I use tween.FROM

Using relative values (-=30px), GSAP should tween the top value in

 

chrome: -30px to 0

firefox: 20px to 50px

 

Instead, GSAP is ignoring the top-value in Firefox and just adds 30px to 50px (calculated value).

 

Fiddle: http://jsfiddle.net/kDAqE/5/

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