Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

translate3d vs css left/top and hardware acceleration

As I understand hardware acceleration on iOS devices is enabled when using translate3d(). So why this test on jsperf shows that using css left/top is faster?

like image 309
Marvin3 Avatar asked Aug 27 '11 07:08

Marvin3


People also ask

Can CSS animations be hardware accelerated?

Hardware-Accelerated CSS on Desktop and Mobile BrowsersCSS animations, transforms and transitions are not automatically GPU accelerated, and instead execute from the browser's slower software rendering engine.

Do CSS animations use GPU?

We already know that animation of transform and opacity via CSS transitions or animations automatically creates a compositing layer and works on the GPU.

Why is it better to use translate () rather than an Position absolute top right bottom left?

So this is due to the absolute positioned macbook sticks to pixel positions, whereas the translate() 'd one can interpolate at sub-pixel positions.

Why do we translate transform in CSS?

The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.


1 Answers

I have used translate3d extensively on iOS in lieu of CSS left/top, and I can say one thing:

It is truly faster for animating things (which jsperf does not seem to do.) My guess is, left/top is faster when benchmarking since nothing is animated and I don't think anything is displayed either.

It is when used in conjunction with transition (or -webkit-transition) that translate3d works its magic.

like image 196
Bryan Menard Avatar answered Oct 15 '22 00:10

Bryan Menard