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,對其進行設定無效。