Can CSS3 transform
values be applied individually?
Details:
For example, in https://jsfiddle.net/eaqvyt1a/
we have the translate(100px, 100px)
, and after 2 seconds, a rotation is needed, so transform: rotate(3deg)
is applied, but it will wipe out the translate
-- this way, it is similar to, when we use background: yellow
then it will wipe out the background-image
property.
So, can we apply the rotate
individual, so that the translate
will stay? If we "concatenate" the strings of translate()
and rotate()
together, that will work, but then it becomes too much of string manipulation, because, what if we need another translate()
, then do we add to that string (then it becomes a longer and longer string and messy), or do we search in that string and remove the original translate
and add the new translate
? It is kind of messy too. That is, can we just say, rotate a little bit, regardless of how much you translated from x and y, just stay there and do the rotation?
P.S. and then, I thought of a way, but requires JavaScript, which is to keep an object of properties we want to transform, for example, { translate: [100,100], rotate: 30}
so that we dynamically create the string and apply to transform
. To change any rotation amount, we first change that object first (like obj.rotate = 45
), and then call the function to get that new string to use for transform
.