SVGSVGElement: animationsPaused() Methode
Baseline
Weitgehend verfügbar
Diese Funktion ist gut etabliert und funktioniert auf vielen Geräten und in vielen Browserversionen. Sie ist seit Januar 2020 browserübergreifend verfügbar.
Die animationsPaused() Methode der SVGSVGElement Schnittstelle überprüft, ob die Animationen im SVG-Dokumentfragment aktuell pausiert sind.
Syntax
js
animationsPaused()
Parameter
Keine.
Rückgabewert
Ein boolean. true, wenn dieses SVG-Dokumentfragment in einem pausierten Zustand ist.
Beispiele
>Überprüfen, ob Animationen pausiert sind
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();
Spezifikationen
| Spezifikation |
|---|
| SVG Animations Level 2> # __svg__SVGSVGElement__animationsPaused> |