Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
omnider

Subpixel animations?

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,

 

I've created this little

See the Pen kqoeu by omnider (@omnider) on CodePen

 to demonstrate what my problem is. Is there any chance to make the animation smoother? Now you can clearly see the image going from pixel to pixel .. is there any way to do some sort of subpixel animation? So far I've tried this, the same with x/y, turning off the autoRound plugin, none of which seems to do it any good.

 

Any ideas would are appreciated :) Cheers

Link to comment
Share on other sites

The browsers force "top" and "left" values to get rounded, so they'll only land on whole pixels even if GSAP is setting the values with precise decimals. Some browsers also apply rounding to 2D transforms as well. However, if you kick things into 3D, it can (in many browsers) offload things to the GPU in a way that allows sub-pixel rendering.

 

You could set a z property to something like 0.01 or recent versions of GSAP have a "force3D" boolean that you can set. Here's a revised codepen that looks smoother at least in webkit browsers:

http://codepen.io/GreenSock/pen/e8caea66998087e88d25deb2ed6096b8

 

Firefox appears to still force some rounding though, so this isn't a perfect fix in all scenarios (I don't think there is such a thing).

  • Like 5
Link to comment
Share on other sites

Thanks a lot for that. Brilliant solution as always!

Link to comment
Share on other sites

  • 5 months later...

 

 

You could set a z property to something like 0.01 or recent versions of GSAP have a "force3D" boolean that you can set.

 

Perfect! I tried setting translateZ in CSS but naturally that didn't work as 2D transforms in GSAP use the matrix syntax, not translate3d.

Link to comment
Share on other sites

Hey Jens. Actually, it shouldn't matter what syntax you use (matrix or list or whatever). If you're having any trouble, feel free to post a simple codepen or jsfiddle that demonstrates the issue and we'll take a peek. 

  • Like 1
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.
×