CSS Typed Object Model API
The CSSTransformValue() constructor creates a new CSSTransformValue object, representing a transform-list value made up of the given CSSTransformComponent objects.
Syntax
new CSSTransformValue(transforms)
Parameters
transforms- : An array of CSSTransformComponent objects.
Exceptions
- TypeError
- : Thrown if
transformsis empty.
- : Thrown if
Examples
Basic usage
const transform = new CSSTransformValue([
new CSSTranslate(CSS.px(10), CSS.px(20)),
new CSSScale(2, 3),
]);
console.log(transform.length); // 2
console.log(transform.toString()); // "translate(10px, 20px) scale(2, 3)"
Handling an empty array
The constructor throws a TypeError if transforms is empty:
try {
const transform = new CSSTransformValue([]);
} catch (e) {
console.log(e); // TypeError
}
Specifications
Browser compatibility
See also
- CSSTransformComponent
- CSSTransformValue.entries()
- CSSTransformValue.forEach()
- CSSTransformValue.is2D
- CSSTransformValue.keys()
- CSSTransformValue.length
- CSSTransformValue.toMatrix()
- CSSTransformValue.values()
- Using the CSS Typed OM
- CSS Typed Object Model API
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
