How is the getBBox() SVGRect calculated?

后端 未结 7 1638
再見小時候
再見小時候 2020-12-04 15:29

I have a g element that contains one or more path elements. As I mentioned in another question, I scale and translate the g element by

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 16:29

    People often get confused by the behavioral difference of getBBox and getBoundingClientRect.

    getBBox is a SVG Element's native method as equivalent to find the offset/clientwidth of HTML DOM element. The width and height is never going to change even when the element is rotated. It cannot be used for HTML DOM Elements.

    getBoundingClientRect is common to both HTML and SVG elements. The bounded rectangle width and height will change when the element is rotated or when more elements are grouped.

提交回复
热议问题