大网数据广告活动
Web 标准与前端开发

SVGAnimatedEnumeration: animVal property

· 52CE 我爱测

The **`animVal`** read-only property of the SVGAnimatedEnumeration interface represents the value of an SVG enumeration.

SVG

The animVal read-only property of the SVGAnimatedEnumeration interface represents the value of an SVG enumeration.

In SVG 2, animVal reflects the non-animated value of the attribute: it is the same as SVGAnimatedEnumeration/baseVal .

Value

An integer representing the value of the enumeration.

The allowed values depend on the attribute that is reflected. This property cannot be written.

Exceptions

  • NoModificationAllowedError DOMException
    • : Thrown if the property is set to any value.

Examples

Basic usage

html,
body,
svg {
  height: 100%;
}
<div>
  <svg viewBox="0 0 100 100" width="200" height="200">
    <clipPath id="clip1" clipPathUnits="userSpaceOnUse">
      <animate
        attributeName="clipPathUnits"
        values="userSpaceOnUse;objectBoundingBox;userSpaceOnUse"
        dur="2s"
        repeatCount="indefinite" />
      <circle cx="50" cy="50" r="25" />
    </clipPath>

    <rect id="r1" x="0" y="0" width="50" height="100" />

    <use clip-path="url(#clip1)" href="#r1" fill="lightblue" />
  </svg>
</div>
<pre id="log"></pre>

The following JavaScript gets the element, and logs the animValue of the SVGClipPathElement.clipPathUnits property.

const clipPath1 = document.getElementById("clip1");
const log = document.getElementById("log");

function displayLog() {
  const animValue = clipPath1.clipPathUnits.animVal;
  const baseValue = clipPath1.clipPathUnits.baseVal;
  log.textContent = `The 'clipPathUnits.animVal' is ${animValue}.\n`;
  requestAnimationFrame(displayLog);
}

displayLog();

Examples

Specifications

Browser compatibility

See also

  • SVGAnimatedEnumeration.baseVal

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。