Thanks!
Somehow i missed that.
Now I also know why there is no finction elementX(event) because that would
be:
   elementX: function(event) {
        return this.pointerX(event) - Position.
                  cumulativeOffset(this.element(event))[0];
   },

Which is a load of calculation everytime which is unneeded. So my client
should cache the position (as long as the element does not move or gets
moved:

var elementX = Position.cumulativeOffset(myElement)[0];

function fireOnEvent(event){
   xpos = Event.pointerX(event) - elementX;
}

Thanks!

Fabian

-----Original Message-----
From:
[EMAIL PROTECTED]
om
[mailto:[EMAIL PROTECTED]
groups.com] On Behalf Of Hill, Greg
Sent: Samstag, 23. September 2006 00:27
To: [email protected]
Subject: [Rails-spinoffs] Re: Getting the coordinates of an event of an
object


Look at the Position code in prototype, I think everything you'll need
is there.  It's near the bottom of the file, unless something changed.

Greg

> -----Original Message-----
> From: [email protected] [mailto:rubyonrails-
> [EMAIL PROTECTED] On Behalf Of Fabian Lange
> Sent: Friday, September 22, 2006 4:09 PM
> To: [email protected]
> Subject: [Rails-spinoffs] Getting the coordinates of an event of an
object
> 
> 
> Hi,
> I just encountered a situation where I want to know the position of
the
> mouse pointer of an element.
> I consider this a pretty basic functionality, but Prototype gives me
only:
> Event.pointerX(event)
> Event.pointerY(event)
> 
> So I thought adding:
> 
>   elementX: function(event) {
>       return this.pointerX(event)-Element.getX(this.element(event));
>   },
> 
>   elementY: function(event) {
>       return this.pointerY(event)-Element.getY(this.element(event));
>   },
> 
> But wait there is no Element.getX. I found out that obtaining the X/y
of
> an
> element is not trivial at all, but even more in this case I expect it
to
> be
> handled in a library.
> 
> Do I miss something or has anyone a reliable and fast implementation
for
> Element.getX?
> 
> Br
> Fabian
> 
> 
> 
> 
> 



--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to