<svg viewBox="0 0 200 100" id="mySvg">
<rect width="100" height="100" fill="blue" />
</svg>SVGAnimatedRect: animVal property / notebook
SVGAnimatedRect: animVal property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const svgElement = document.getElementById("mySvg");
const animatedRect = svgElement.viewBox.animVal;
// Log the animated value (assuming an animation is applied)
console.log(animatedRect.x);
console.log(animatedRect.y);
console.log(animatedRect.width);
console.log(animatedRect.height);