SVGAnimatedRect: baseVal-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Die baseVal-Eigenschaft der SVGAnimatedRect-Schnittstelle, die schreibgeschützt ist, repräsentiert den aktuellen, nicht animierten Wert des viewBox-Attributs eines SVG-Elements.

Diese Eigenschaft spiegelt den Wert des viewBox-Attributs des SVG-Elements als schreibgeschütztes DOMRect-Objekt wider. Sie bietet Zugriff auf das statische Rechteck, das durch das viewBox-Attribut definiert ist, einschließlich der x-, y-, width- und height-Werte.

Wert

Ein DOMRect-Objekt, das den aktuellen, nicht animierten Wert des viewBox-Attributs repräsentiert.

Beispiele

html
<svg viewBox="0 0 200 100" id="mySvg">
  <rect width="100" height="100" fill="blue" />
</svg>
js
const svgElement = document.getElementById("mySvg");
const animatedRect = svgElement.viewBox.baseVal;

// Access the non-animated base value
console.log(animatedRect.x); // 0
console.log(animatedRect.y); // 0
console.log(animatedRect.width); // 200
console.log(animatedRect.height); // 100

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGAnimatedRect__baseVal

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
baseVal

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch