SVGTransform: type プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
type
が SVGTransform
インターフェイスの読み取り専用プロパティで、このインターフェイスで定義されている SVG_TRANSFORM_*
定数のいずれかによって指定される、適用された座標変換の type
を表します。
値
整数です。値の型を unsigned short で表します。
例
座標変換の種類を特定
html
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<rect id="rect" x="50" y="50" width="100" height="100" fill="blue" />
</svg>
js
const rect = document.getElementById("rect");
const transformList = rect.transform.baseVal;
// 移動の座標変換を作成して追加
const translateTransform = rect.ownerSVGElement.createSVGTransform();
translateTransform.setTranslate(20, 30);
transformList.appendItem(translateTransform);
// 追加された座標変換の種類をチェック
console.log(transformList.getItem(0).type); // 出力: 2 (SVG_TRANSFORM_TRANSLATE)
仕様書
Specification |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGTransform__type |