SVGSVGElement:unpauseAnimations() 方法
SVGSVGElement 介面的 unpauseAnimations() 方法會恢復(即取消暫停)當前正在執行且定義在 SVG 文件片段中的動畫,使動畫時鐘從暫停時的時間點繼續播放。
語法
js
unpauseAnimations()
引數
無。
返回值
無(undefined)。
示例
恢復動畫
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 Animations</button>
<button id="resumeBtn">Resume Animations</button>
<pre id="status"></pre>
js
const svgElement = document.getElementById("exampleSVG");
const pauseButton = document.getElementById("pauseBtn");
const resumeButton = document.getElementById("resumeBtn");
const statusDisplay = document.getElementById("status");
pauseButton.addEventListener("click", () => {
svgElement.pauseAnimations();
statusDisplay.textContent = "Animations paused.";
});
resumeButton.addEventListener("click", () => {
svgElement.unpauseAnimations();
statusDisplay.textContent = "Animations resumed.";
});
規範
| 規範 |
|---|
| SVG 動畫級別 2 # __svg__SVGSVGElement__unpauseAnimations |
瀏覽器相容性
載入中…