4 ms·
>Properties like margin-top and top can animate just as smoothly as a transleY transformation. Interesting, I always thought that because margin changes the la
by iaml 6y ago
>Properties like margin-top and top can animate just as smoothly as a transleY transformation.
Interesting, I always thought that because margin changes the layout it triggers the associated recalculations thus is slower than translate which doesn't
- chrismorgan 6y agoOh, in absolute terms it’s definitely slower in that way, but the other thing to realise is that layout is cheaper in Firefox than in other production browsers on most computers, because of other parts of Servo that have been landed, such as the CPU-parallelised CSS engine. (Servo CPU-parallelises all of layout, but I don’t think Firefox has adopted that yet.) The consequence is in many cases the cost of layout is still negligible, and it can keep going smoothly. The situation on animating things like margin-top and height is pretty much this: (a) under the old regime, jank was pretty much guaranteed; (b) in Servo, it’s actually pretty hard to cause jank—you’ve got to have a significant number of layers, many more than the typical page will have; (c) Firefox is in between, that if your layers aren’t too complex you will probably avoid jank. (Please note that I’m not encouraging animating layout-affecting properties needlessly; you should almost certainly animate a transformation instead, because it requires strictly less work to be done. But on the other hand, if you have `position: absolute`, it’s cool to know that adjusting `top` (with unconstrained `bottom`) will perform as well as a translateY transformation under WebRender.)