SVGAnimatedNumberList: animVal 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

SVGAnimatedNumberList 接口的只读属性 animVal 表示可动画属性的当前动画值,该属性接受一个 <number> 值列表。

此属性反映了 <svg> 元素的 viewBox 属性、feColorMatrix 元素的 values 属性,以及 <rect><polygon><polyline> 元素的 points 属性,作为一个只读的 SVGNumberList,提供了对 points 属性定义的点的动态更新列表的访问。

一个 SVGNumberList 对象,表示该属性的动画值。该列表包含一个或多个数字,对应于属性中指定的各个数字值。

示例

js
const rect = document.querySelector("rect");

// Set the animatable 'points' attribute with number values
rect.setAttribute("points", "10,10 20,10 20,20 10,20");

// Access the SVGAnimatedNumberList object
const points = rect.points;

console.dir(points.animVal); // the animated state

规范

规范
Scalable Vector Graphics (SVG) 2
# __svg__SVGAnimatedNumberList__animVal

浏览器兼容性

另见