From: Eric Bednarz on
Garrett Smith <dhtmlkitchen(a)gmail.com> writes:

> Eric Bednarz wrote:

>> Since I never attempted to retrieve offset values of relatively
>> positioned elements by script, […]

> "Offset" values and top/left style values are different
> things.

Ah.

> Offset", to me, is about the badly defined and highly
> inconsistent "offsetTop", "offsetLeft", and "offsetParent".

“Offset”, to CSS 2.1, is about section 9.3.2.

>> <http://bednarz.nl/tmp/relative/>

(Unfortunately I had to move that:)

<http://bednarz.nl/sandbox/js/relative/>

> What I do not understand is the "expected" column. What are the
> expectations coming from?

See above; is the specification (candidate) an unreasonable point of
reference?

>> - jQuery does nothing more than returning the wrong results provided by the
>> getComputedStyle/currentStyle branch
>
> To retrieve element coordinate offsets with jQuery,

Anybody who understands the difference between relative and absolute
positioning should be able to understand why I am having a hard time to
understand this persistant fixation on wanting to get element
coordinates in respect to anything else but that element's position in
the normal flow.

> jQuery's offset
> method would be the method for that.

I want to retrieve CSS values, and jQuery (as do some other libraries)
pretends to provide a method to do that; unsurprisingly, the cross
browser proposition is restricted to a tiny subset of the possible use
cases.
From: Eric Bednarz on
David Mark <dmark.cinsoft(a)gmail.com> writes:

> Here's the thing. You can make use of offsetLeft/Top to check your
> work. For instance, take your relative position quandary.
^^^^^^^^
OK.

> […] grab the offsetLeft and offsetTop (verify
> beforehand that they are available and numbers of course) then set the
> left and top styles to those. Simply put:-
>
> var offsetLeft = el.offsetLeft;
> var offsetTop = el.offsetTop;
>
> el.style.left = offsetLeft + 'px';
> el.style.top = offsetTop + 'px';

Unless I miss someting, that strategy is only useful for absolute
positioning (I like it, and I use it, in that context).
From: David Mark on
Eric Bednarz wrote:
> Garrett Smith <dhtmlkitchen(a)gmail.com> writes:
>
>> Eric Bednarz wrote:
>
>>> Since I never attempted to retrieve offset values of relatively
>>> positioned elements by script, […]
>
>> "Offset" values and top/left style values are different
>> things.
>
> Ah.
>
>> Offset", to me, is about the badly defined and highly
>> inconsistent "offsetTop", "offsetLeft", and "offsetParent".
>
> “Offset”, to CSS 2.1, is about section 9.3.2.
>
>>> <http://bednarz.nl/tmp/relative/>
>
> (Unfortunately I had to move that:)
>
> <http://bednarz.nl/sandbox/js/relative/>
>
>> What I do not understand is the "expected" column. What are the
>> expectations coming from?
>
> See above; is the specification (candidate) an unreasonable point of
> reference?
>
>>> - jQuery does nothing more than returning the wrong results provided by the
>>> getComputedStyle/currentStyle branch
>> To retrieve element coordinate offsets with jQuery,
>
> Anybody who understands the difference between relative and absolute
> positioning should be able to understand why I am having a hard time to
> understand this persistant fixation on wanting to get element
> coordinates in respect to anything else but that element's position in
> the normal flow.
>
>> jQuery's offset
>> method would be the method for that.
>
> I want to retrieve CSS values, and jQuery (as do some other libraries)
> pretends to provide a method to do that; unsurprisingly, the cross
> browser proposition is restricted to a tiny subset of the possible use
> cases.

My Library's is pretty good. The one in the new primer (see my site) is
better.
From: David Mark on
Eric Bednarz wrote:
> David Mark <dmark.cinsoft(a)gmail.com> writes:
>
>> Here's the thing. You can make use of offsetLeft/Top to check your
>> work. For instance, take your relative position quandary.
> ^^^^^^^^
> OK.
>
>> […] grab the offsetLeft and offsetTop (verify
>> beforehand that they are available and numbers of course) then set the
>> left and top styles to those. Simply put:-
>>
>> var offsetLeft = el.offsetLeft;
>> var offsetTop = el.offsetTop;
>>
>> el.style.left = offsetLeft + 'px';
>> el.style.top = offsetTop + 'px';
>
> Unless I miss someting, that strategy is only useful for absolute
> positioning (I like it, and I use it, in that context).

Nope. Works like a charm for relative and fixed. Why wouldn't it?
From: David Mark on
David Mark wrote:
> Eric Bednarz wrote:
>> David Mark <dmark.cinsoft(a)gmail.com> writes:
>>
>>> Here's the thing. You can make use of offsetLeft/Top to check your
>>> work. For instance, take your relative position quandary.
>> ^^^^^^^^
>> OK.
>>
>>> […] grab the offsetLeft and offsetTop (verify
>>> beforehand that they are available and numbers of course) then set the
>>> left and top styles to those. Simply put:-
>>>
>>> var offsetLeft = el.offsetLeft;
>>> var offsetTop = el.offsetTop;
>>>
>>> el.style.left = offsetLeft + 'px';
>>> el.style.top = offsetTop + 'px';
>> Unless I miss someting, that strategy is only useful for absolute
>> positioning (I like it, and I use it, in that context).
>
> Nope. Works like a charm for relative and fixed. Why wouldn't it?

And it does appear you are missing (snipped?) the latter part of the
explanation. Remember when I said to check if it moved. That's the
key. Again, vive la différence! :)