views:

62

answers:

1

Hello there, 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

A: 

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

Evadne Wu
Worked like a charm! Many thanks!
ienes
Umm well it works for circles only. I have paths which obviously don't have it..
ienes
then try `x` and `y`. dump `raphaelElement.attr()` and see what attributes it has?
Evadne Wu
Every object contains only four properties: fill, path, stroke, stroke-width.
ienes
Solved by using getBBox().x and getBBox().y respectively.
ienes