transform-stack
v0.0.0
Published
Add/remove individual transformations from a CSS transform style
Downloads
5
Maintainers
Readme
transform-stack
Add/remove individual transformations from a DOM node's CSS transform style, with the hopes of minimising interference with other transforms being applied from other parts of your code.
Usage
push = transform(node)
Create a new transform stack for node
.
pop = push(value)
Appends a new transform operation of value
to the node's transform style.
This should just be a string, e.g. translate(50px, 0)
.
Returns a pop
function, which you can use to remove the transform later.
pop()
Removes the previously applied transform. Note: if you have two transforms of exactly the same type and values, you may run into issues with transform order.
push()
When calling push
with no arguments, you will be given an array in return
that contains each transform in the stack, e.g.:
[
"translate(50px, 0)"
, "rotate(45deg)"
, "scale(0.5, 0.5)"
]
License
MIT. See LICENSE.md for details.