What should getBoundingClientRect() on a transformed SVG element return?

谁说我不能喝 提交于 2019-12-21 09:16:41

问题


Today I tested what happens when you use getBoundingClientRect() on an SVG element that has been rotated.

Test: http://phrogz.net/svg/getBoundingClientRect-on-rotated-elements.html

The result is that:

  • Chrome, Safari, Opera, and IE appear to calculate the local (untransformed) bounding box of the element, and then return the client rect for that bounding box. This can result in a client rect larger than seems appropriate.

  • Firefox, on the other hand, clips the client rect to fit the element itself.

 
                         

 

Which behavior is correct according to the specifications?

For what it's worth, I prefer the Firefox behavior, but (absent understanding the specs) think that Firefox's deviation should be considered a bug.


回答1:


Non-firefox browsers don't seem to give useful results and don't seem to match the relevant specifications either.

The CSSOM View Module delegates to the SVG specification which says it's the tight bounding box after transforms not the tight bounding box transformed so I maintain that I implemented it correctly.



来源:https://stackoverflow.com/questions/10628851/what-should-getboundingclientrect-on-a-transformed-svg-element-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!