SVGSVGElement:animationsPaused() 方法
SVGSVGElement 介面的 animationsPaused() 方法用於檢查 SVG 文件片段中的動畫當前是否處於暫停狀態。
語法
js
animationsPaused()
引數
無。
返回值
布林值。如果此 SVG 文件片段處於暫停狀態,則為 true。
示例
檢查動畫是否暫停
html
<svg id="exampleSVG" width="200" height="100">
<circle cx="50" cy="50" r="30" fill="blue">
<animate
attributeName="cx"
from="50"
to="150"
dur="2s"
repeatCount="indefinite" />
</circle>
</svg>
<button id="pauseBtn">Pause/Resume Animations</button>
<pre id="status"></pre>
js
const svgElement = document.getElementById("exampleSVG");
const pauseButton = document.getElementById("pauseBtn");
const statusDisplay = document.getElementById("status");
function updateStatus() {
const isPaused = svgElement.animationsPaused();
statusDisplay.textContent = `Animations paused: ${isPaused}`;
}
pauseButton.addEventListener("click", () => {
if (svgElement.animationsPaused()) {
svgElement.unpauseAnimations();
} else {
svgElement.pauseAnimations();
}
updateStatus();
});
// Initialize the status display
updateStatus();
規範
| 規範 |
|---|
| SVG 動畫級別 2 # __svg__SVGSVGElement__animationsPaused |
瀏覽器相容性
載入中…