Transform
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.
Usage
Parameters
The generateTransform function accepts only one options parameter used to set the default values. It can have the following properties.
property
type
description
units
object
holds properties to change the default units
units.perspective
string
changes default unit for perspective
units.rotate
string
changes default unit for rotate
units.skew
string
changes default unit for skew
units.translate
object
translate xy can have different props than z
units.translate.xy
string
changes default unit for translateX/Y
units.translate.z
string
change default unit for translateZ
Default options
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.
parameters
type
description
transforms
object
| object[]
can have any of the transform functions as properties
overrides
object
options
object that will override units for this function call only
The transforms
parameter can have one or more of the following properties.
parameters
description
matrix
Describes a homogeneous 2D transformation matrix
matrix3d
Describes a 3D transformation as a 4×4 homogeneous matrix
perspective
Sets the distance between the user and the z=0 plane
rotate
Rotates an element around a fixed point on the 2D plane
rotateX
Rotates an element around the horizontal axis
rotateY
Rotates an element around the vertical axis
rotateZ
Rotates an element around the z-axis
rotate3d
Rotates an element around a fixed axis in 3D space
scale
Scales an element up or down on the 2D plane
scaleX
Scales an element up or down horizontally
scaleY
Scales an element up or down vertically
scaleZ
Scales an element up or down along the z-axis
scale3d
Scales an element up or down in 3D space
skew
Skews an element on the 2D plane
skewX
Skews an element in the horizontal direction
skewY
Skews an element in the vertical direction
translate
Translates an element on the 2D plane
translateX
Translates an element horizontally
translateY
Translates an element vertically
translateZ
Translates an element along the z-axis
translate3d
Translates an element in 3D space
Matrix
The matrix
property describes a homogeneous 2D transformation matrix.
Matrix3d
Similar to matrix, the matrix3d
property describes a 3D transformation as a 4×4 homogeneous matrix.
Perspective
Although not commonly used, the perspective
property sets the distance between the user and the z=0 plane.
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.
Rotate3d
The property rotate3d
will allow for the rotation around a fixed axis in 3D space
Scale
Using the Scale
property allows for scaling an element up or down on the 2D plane
ScaleX/Y/Z
Similar to the scale property, scaleX
, scaleY
and scaleZ
will only have effect on their respective axes.
Scale3d
When dealing with scaling the the 3D space, the scale3d
property will allow you to change the scaling on all dimensions at once.
Skew
The property skew
can be used to skew an element on the 2D plane.
SkewX/Y
The simpler skewX
and skewY
are a subset of the skew function and will skew an element in the horizontal or vertical direction, respectively.
Translate
The translate
property allows the user to move an element on the 2D plane.
TranslateX/Y/Z
The axis locked translates, translateX
, translateY
, translateZ
allow for an element to be moved on their specific planes.
Translate3d
A junction of the previous translate functions, the translate3d
property is used to translate an element in all planes at once.
Last updated