SVGAnimatedRect: animVal 屬性
SVGAnimatedRect 介面的只讀屬性 animVal,表示 SVG 元素的 viewBox 屬性的當前動畫值,其型別為一個只讀的 DOMRectReadOnly 物件。在動畫期間,它提供了對矩形動態狀態的訪問,包括 x、y、width 和 height 值。
如果沒有應用動畫,animVal 屬性將反映 SVG 元素的 viewBox 屬性值,並且將與 SVGAnimatedRect.baseVal 相同。
值
一個 DOMRectReadOnly 物件,表示 viewBox 屬性的動畫值。
示例
html
<svg viewBox="0 0 200 100" id="mySvg">
<rect width="100" height="100" fill="blue" />
</svg>
js
const svgElement = document.getElementById("mySvg");
const animatedRect = svgElement.viewBox.animVal;
// Log the animated value (assuming an animation is applied)
console.log(animatedRect.x);
console.log(animatedRect.y);
console.log(animatedRect.width);
console.log(animatedRect.height);
規範
| 規範 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGAnimatedRect__animVal |
瀏覽器相容性
載入中…