开发者

jQuery $.position() on Safari & Chrome

开发者 https://www.devze.com 2023-01-06 22:10 出处:网络
I have an issue using $.position to retrieve the relative x/y offset on an element. It was mentioned before that both Safari and Chrome differ in handling it as the others.

I have an issue using $.position to retrieve the relative x/y offset on an element. It was mentioned before that both Safari and Chrome differ in handling it as the others.

I'm using Raphael-JS.

To cut the long story short, what I have is an SVG element wrapped by the parent, centered DIV wrapper:

<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. Both Chrome and Safari return negative values for x offset and开发者_开发知识库 0 for y.

Any help will be appreciated, Best regards


Try using Raphael’s cx and cy attributes, like in circle.attr("cx") and circle.attr("cy").

0

精彩评论

暂无评论...
验证码 换一张
取 消