How do I get the global coordinates of a grouped svg element?

后端 未结 2 1977
独厮守ぢ
独厮守ぢ 2021-01-02 13:32

Suppose I have the following document (fiddle):


    
        

        
2条回答
  •  情歌与酒
    2021-01-02 14:17

    You could use the function .getBoundingClientRect() to get the bounding box. Then, use height, width, top and left values to find the center position of your element.

    Refer to https://developer.mozilla.org/es/docs/Web/API/Element/getBoundingClientRect

提交回复
热议问题