简体   繁体   English

Safari和Chrome上的jQuery $ .position()

[英]jQuery $.position() on Safari & Chrome

I have an issue using $.position to retrieve the relative x/y offset on an element. 我在使用$ .position检索元素上的相对x / y偏移量时遇到问题。 It was mentioned before that both Safari and Chrome differ in handling it as the others. 之前提到过,Safari和Chrome在处理方式上与其他方式不同。

I'm using Raphael-JS. 我正在使用Raphael-JS。

To cut the long story short, what I have is an SVG element wrapped by the parent, centered DIV wrapper: 长话短说,我所拥有的是由父中心 DIV包装器包装的SVG元素:

<div> 
    <svg>
        <path/>
    </svg>
</div>

In every browser an object returned by $.position which runs on 'path' element gives more or less the correct value. 在每个浏览器中,由$ .position返回的,在'path'元素上运行的对象或多或少给出正确的值。 Both Chrome and Safari return negative values for x offset and 0 for y. Chrome和Safari都为x偏移返回负值,为y返回0。

Any help will be appreciated, Best regards 任何帮助将不胜感激,最好的问候

尝试使用Raphael的cxcy属性,例如circle.attr("cx")circle.attr("cy")属性。

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

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