I think prototype is missing a function that calculates an absolute position for an element. I coded this for it: Element.Methods.getAbsolutePosition function(element){ var curleft = curtop = 0; var obj=$(element); if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return {''left'':curleft,''top'':curtop}; } It is based on the code from http://www.quirksmode.org/js/findpos.html. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I think that''s Element.positionedOffset Copied from 1.5.1_rc4 positionedOffset: function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; if (element) { if(element.tagName==''BODY'') break; var p = Element.getStyle(element, ''position''); if (p == ''relative'' || p == ''absolute'') break; } } while (element); return [valueL, valueT]; } On 8/17/07, Alexsiri7 <alexsiri7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I think prototype is missing a function that calculates an absolute > position for an element. I coded this for it: > > Element.Methods.getAbsolutePosition> function(element){ > var curleft = curtop = 0; > var obj=$(element); > if (obj.offsetParent) { > curleft = obj.offsetLeft > curtop = obj.offsetTop > while (obj = obj.offsetParent) { > curleft += obj.offsetLeft > curtop += obj.offsetTop > } > } > return {''left'':curleft,''top'':curtop}; > } > > It is based on the code from http://www.quirksmode.org/js/findpos.html. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Gareth, thanks a lot for that info! Although that was not the function I was looking for, I found about the Position methods that way (I assumed that if they were anywhere, they would be in Element.Methods), and found cumulativeOffset. Well, thanks about that, I could complete "Shrinking to a position" for scriptaculous: http://dev.rubyonrails.org/ticket/9311. Regards, Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---