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 |
| holds properties to change the default units |
units.perspective |
| changes default unit for |
units.rotate |
| changes default unit for |
units.skew |
| changes default unit for |
units.translate |
| translate xy can have different props than z |
units.translate.xy |
| changes default unit for |
units.translate.z |
| change default unit for |
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 |
| can have any of the transform functions as properties |
overrides |
|
|
The transforms
parameter can have one or more of the following properties.
parameters | description |
| Describes a homogeneous 2D transformation matrix |
| Describes a 3D transformation as a 4×4 homogeneous matrix |
| Sets the distance between the user and the z=0 plane |
| Rotates an element around a fixed point on the 2D plane |
| Rotates an element around the horizontal axis |
| Rotates an element around the vertical axis |
| Rotates an element around the z-axis |
| Rotates an element around a fixed axis in 3D space |
| Scales an element up or down on the 2D plane |
| Scales an element up or down horizontally |
| Scales an element up or down vertically |
| Scales an element up or down along the z-axis |
| Scales an element up or down in 3D space |
| Skews an element on the 2D plane |
| Skews an element in the horizontal direction |
| Skews an element in the vertical direction |
| Translates an element on the 2D plane |
| Translates an element horizontally |
| Translates an element vertically |
| Translates an element along the z-axis |
| 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