Generate multiple transform function strings easily without the need of template strings.
This will give you more flexibility when creating or updating transform functions all over your app. It has sensible defaults, but any length value can be overridden either in the generator function or the actual value declaration.
The generateTransform function accepts only one options parameter used to set the default values. It can have the following properties.
Default options
{ units: { perspective:'px',// Affects the perspective() function rotate:'deg',// Affects rotate, rotateX/Y/Z and rotate3d skew:'deg',// Affects skew, skewX/Y translate: { xy:'%',// Affects translate, translateX/Y and translate3d z:'px',// Affects translateZ and translate3d } }}
Note: The functions matrix, matrix3d, scale, scaleX, scaleY, scaleZ, scale3d do not user units and thus can not be overridden.
Transform function
The transform is the result of the generator function. You have to call it to get an actual transform string as output and it can be used throughout your app.
The transforms parameter can have one or more of the following properties.
Matrix
The matrix property describes a homogeneous 2D transformation matrix.
Although not commonly used, the perspective property sets the distance between the user and the z=0 plane.
// Usagetransform({ perspective: number | string })
Rotate/X/Y/Z
The rotate property allows for the rotation of an element around a fixed point on the 2D plane. The some of the other rotation properties have the same signature, but affect only a single axis. The rotateX property describes the rotation of an element around the horizontal axis, rotateY will affect the vertical axis, while rotateZ will work only on the z-axis.
// Usagetransform({ rotate: number | string })transform({ rotateX: number | string })transform({ rotateY: number | string })transform({ rotateZ: number | string })
Rotate3d
The property rotate3d will allow for the rotation around a fixed axis in 3D space