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 |
浏览器兼容性
加载中…