Reputation: 27022
When using GSAP to perform a transition where an element is scaled equally in both dimensions, there seems to be a choice between using scale
, or both height
and width
.
Which is better, as in will result in a higher frame rate? Or if there are conditions on the element / other transitions / DOM / CSS / browser / processor / GPU (/anything else?) that makes one better over the other, what are these?
Upvotes: 1
Views: 7651
Reputation: 169
One of the differences in using Scale Vs Width/Height is the use of CSS but you have to keep in mind while using Scale it will resize from the center of the object, while using Width/Height it will be from top left. Unless you change the transform Origin.
One major factor is the content of the object you are resizing, if you use Scale and the object has content, it will also scale everything inside, while Width/Height will not.
Upvotes: 3
Reputation: 5737
From what I can understand, what scaleX
and scaleY
do is that they use CSS's transform
in the background and generally, using transforms produces a much smoother result because of sub-pixel rendering. Also, if you add force3D: true
on the same element as well, it forces it to render it on its own GPU layer hence, hardware accelerated. And that happens because it adds translate3d: (0px, 0px, 0px)
onto the same element. So in my opinion, manipulating transform
related properties is much better.
Although, this article by Paul Irish
talks about moving elements (i.e. moving with translate
vs top
and left
), but I believe the same holds true in our case.
Here is a quick jsFiddle for you to play around with.
Upvotes: 2