gpt4 book ai didi

jquery - Firefox 中的 SVG 偏移问题

转载 作者:行者123 更新时间:2023-12-01 04:54:32 33 4
gpt4 key购买 nike

在 Firefox 12.0 或更高版本中,在 SVG(根)元素上调用时,.offset().position() 返回意外值。

结果值是“左”组件最左边子组件的 x 坐标和“顶部”组件最上面子组件的 y 坐标。

$(this.SvgObject).offset().left / $(this.SvgObject).offset().top

在 Firefox 中返回非预期值。

但是当我获取父偏移量时,它给出了正确的值(即):

$(this.SvgObject).parent().offset().left 

但这不是正确的方法。

请引用this bug report 。他们回复道:

"Unfortunately we're not planning on fixing bugs relating to SVG any time soon:"

如何在 SVG 中解决这个问题?

最佳答案

我遇到了同样的问题,我只是在开始绘制拉斐尔图之前创建了一个假边界,这解决了问题。

// adding following rect just to set the boundary of svg element (firefox)
paper.rect(0,0,paperWidth,paperHeight,0).attr({stroke: "#fff"});

关于jquery - Firefox 中的 SVG 偏移问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15629183/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com