简体   繁体   English

变换后的SVG元素上的getBoundingClientRect()应该返回什么?

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

Today I tested what happens when you use getBoundingClientRect() on an SVG element that has been rotated. 今天我测试了在已经旋转的SVG元素上使用getBoundingClientRect()时会发生什么。

Test: http://phrogz.net/svg/getBoundingClientRect-on-rotated-elements.html 测试: 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 . Chrome,Safari,Opera和IE似乎计算元素的本地(未转换)边界框,然后返回该边界框的客户端矩形。 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. 另一方面,Firefox会剪切客户端矩形以适应元素本身。


两种情况的视觉外观;

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 . 对于它的价值,我更喜欢Firefox的行为 ,但(缺乏对规格的理解) 认为 Firefox的偏差应该被认为是一个bug

Non-firefox browsers don't seem to give useful results and don't seem to match the relevant specifications either. 非firefox浏览器似乎没有提供有用的结果,似乎也没有匹配相关的规范。

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. CSSOM视图模块委托给SVG规范,该规范说它是转换后的紧密边界框而不是转换的紧密边界框,所以我认为我正确地实现了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM