转换后的SVG元素上的getBoundingClientRect()应该返回什么? [英] What should getBoundingClientRect() on a transformed SVG element return?

查看:324
本文介绍了转换后的SVG元素上的getBoundingClientRect()应该返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我测试了当您使用 getBoundingClientRect() 在已旋转的SVG元素上.

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

结果是:

  • Chrome,Safari,Opera和IE似乎在计算该元素的本地(未转换)边界框,然后返回该边界框的客户端rect .这可能会导致客户端的rect超出适当的大小.

  • 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会裁剪客户端矩形以适合元素本身.

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

 
                           

 
                           

哪种行为符合规范是正确的?

Which behavior is correct according to the specifications?

对于它的价值,我更喜欢Firefox行为,但是(缺乏理解规范)认为,认为Firefox的偏差应为考虑了错误. >

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浏览器似乎也没有提供有用的结果,而且似乎也不符合相关规范.

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

CSSOM视图模块委托SVG规范,它说的是变换后的紧定边界框,而不是紧密边界框已转换,因此我认为我正确实现了它.

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.

这篇关于转换后的SVG元素上的getBoundingClientRect()应该返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆