getPosition defaults to finding the position relative to the element's
offset parent. If you want to get it relative to the entire document, you
have to use getPosition(document.body) (window also appears to work).

Getting the position relative to some arbitrary element is much more
difficult. See Element.Position.js in MooTools More for an example.

On Thu, Sep 16, 2010 at 3:18 AM, Andrea Dessì <[email protected]> wrote:

> Finally with getPosition(window) I get what i want:
> http://mootools.net/shell/Aaqvy/4/
>
> and there was also a logic error when calculating
> the width and height.
>
> let's go back to school :P
>
> :)
>
> <http://mootools.net/shell/Aaqvy/4/>
> --
> Andrea
>
> On Thu, Sep 16, 2010 at 11:49, Andrea Dessì <[email protected]> wrote:
>
>> I've seen your corrections and works :)
>>
>> I only have a doubt, the target was
>> to position a div element referring to the image, and not
>> its container.
>>
>> So in the second code http://mootools.net/shell/Aaqvy/2/
>> $('mapContainer') should not be used.
>>
>> And because of this I was getting the positions relative to
>> the document :) which were expected to be the "absolute" right.
>>
>> --
>> Andrea
>>
>>
>>
>> On Thu, Sep 16, 2010 at 11:44, MIhaitza <[email protected]> wrote:
>>
>>> correction :)
>>> http://mootools.net/shell/Aaqvy/2/
>>>
>>> On Sep 16, 12:28 pm, MIhaitza <[email protected]> wrote:
>>> > .getPosition() works fine.
>>> > but $('the_id').getPosition() -< get's the position relative to the
>>> > body
>>> >
>>> > lookhttp://mootools.net/shell/Aaqvy/1/
>>> >
>>> > On Sep 16, 11:26 am, Andrea Dessì <[email protected]> wrote:
>>> >
>>> > > Hi all,
>>> >
>>> > > I'm trying to inject a div with absolute position,
>>> > > and its css properties top/left/width/heigth
>>> > > are relative to another element.
>>> >
>>> > > Please see this example:http://mootools.net/shell/Aaqvy/
>>> >
>>> > > Everything works well getting the positions of the image
>>> > > using the .getPosition() function.
>>> >
>>> > > If you remove the comment in the css
>>> > > (or just go herehttp://mootools.net/shell/AJYms/,
>>> > > it's the same code but with different css)
>>> >
>>> > > .getPosition() seems it's returning wrong values.
>>> >
>>> > > There's a way to fix it or a workaround? :)
>>> > > Maybe it's my code fault.
>>> >
>>> > > Thank you,
>>> > > Andrea
>>>
>>
>>
>

Reply via email to