SVGSVGElement: currentScale 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

SVGSVGElement 接口的 currentScale 属性反映了相对于初始视图的当前缩放因子,用于考虑用户对最外层 <svg> 元素的缩放和移动操作。

DOM 属性 currentScalecurrentTranslate 等价于 2x3 矩阵 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]。如果启用了“缩放”(即 zoomAndPan="magnify"),那么其效果就像在 SVG 文档片段的最外层(即在最外层 <svg> 元素之外)应用了一个额外的变换。

如果 <svg> 元素不在最外层,那么 currentScale 始终为 1,对其进行设置无效。