I did some basic benchmarks and even the deeply nested ones was still
pretty fast. I'm going to look into possibly adding these checks
though.

distance(firstElement, secondElement) doesn't really seem to fit with
typical jQuery methods. Essentially distance would be doing the exact
same thing and would still result in the situation where negative
numbers apply. Getting the offset of an element relative to another
makes sense to me. Even having the negative number makes sense but I'm
prolly just too close to the code.

Is this optional referenceElement confusing? The default for
referenceElement is the body tag if that helps any. If you position
something outside the window then it also has negative offset.

--
Brandon Aaron

On 10/4/06, Paul Bakaus <[EMAIL PROTECTED]> wrote:
> Hi there,
> maybe adding a referenceElement for offset is a bit too confusing - I would
> personally prefer a second method called something like
> distance(firstElement, secondElement) .
> This way you don't have the negative offset problem. For your function, it's
> maybe smart to do a couple of more checks:
>
> 1. element does not have a positioned parent and is not positioned -> do it
> the way like proposed, recursive
> 2. element does not have a positioned parent and is positioned       -> just
> get position values from the element itself (way faster)
> 3. element has a positioned parent and is positioned                     ->
> do 2 for the element end then do 1 for the parent
> 4. element has a positioned parent and is not positioned                ->
> do 1 for the element and then 3 for the parent
>
> Good work, tell me wether you want to add it to dimensions.js if ready!
>
> 2006/10/4, Brandon Aaron <[EMAIL PROTECTED]>:
> >
> > Okay so I've modified the offset plugin to take an optional param
> > called referenceElement. If passed in, then it will be used to get the
> > relative offset. Now here is the situation. If the referenceElement is
> > a parent, then the number is positive. If the referenceElement is a
> > child, then the number is negative. That is unless the child is
> > negatively positioned above the parent.
> >
> > My question is: Should the returned offset always be positive or
> > should it be negative if it is a child?
> >
> > --
> > Brandon Aaron
> >
> > On 10/3/06, Brandon Aaron < [EMAIL PROTECTED]> wrote:
> > > On 10/3/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> > > > What about using 'px' as default unit? That way you could write:
> > > > $().top(10).left(10) - and the 'px' is added automatically. In case a
> > > > string is passed you would take that value as is:
> > > > $().top('10%').left('10%').
> > >
> > > That works for me.
> > >
> > > --
> > > Brandon Aaron
> > >
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
>
>
> --
> Paul Bakaus
> Web Developer
> ------------------------
> Hildastr. 35
> 79102 Freiburg
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
>

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to