Anyone have any thoughts on adding a function like that to the "simulated"
area of prototype as mouseenter/mouseleave events (such as the ones IE has
natively)? It'd be handy to have a cross-browser implementation of those
events. I'm not sure what it would take to simulate events as opposed to
properties or functions, but that would definitely be neat...

-Jerod

On 5/11/07, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
>
>
> It may be the hard way, but I think it also requires less explanation.
> It's relatively clear that, if you want to tell when the mouse leaves an
> element, you can exit a mouseout observer if the pointer is still within
> the element.  The method that you link to on quirksmode, while perhaps
> more efficient since it relies mostly on properties rather than
> functional calls and mathematics seems to be far more confusing.  I'd go
> with the pointer arithmetic, especially since the nitty-gritty math is
> hidden by the Position.within() function call.
>
> - Dash -
>
> Tom Gregory wrote:
> > Correct behavior.
> >
> > You're seeing it because of event bubbling.  PPK explains this
> > nicely, as well as providing a short cross-browser solution similar
> > to Prototype's Event.element();
> > http://www.quirksmode.org/js/events_mouse.html
> >
> > Checking mouse position like you're trying to do is the hard way.  =)
> >
> >
> > TAG
> >
> > On May 11, 2007, at 6:40 AM, Sudara wrote:
> >
> >
> >> Hello.
> >>
> >> I spent an hour or three chasing down a desired effect that mootools
> >> implements, namely the simulation of onmouseleave and onmouseenter
> >> events.
> >>
> >> Why?
> >>
> >> Lets say you have a Menu. A ul element that contains many li elements.
> >> If you want to have a function (maybe an effect) fire when the mouse
> >> moves outside of the ul, you are out of luck. Observe the mouseout
> >> function like so:
> >>
> >> Event.observe(nav, 'mouseout', function(e) {
> >>      // you would think this would work
> >>      alert('mouse is outside of nav?...');
> >> });
> >>
> >> and what actually happens is that every time the mouse leaves the
> >> element OR crosses the boundary of a child element (li), the event is
> >> fired.
> >>
> >> Instead of implementing onmouseleave/onmouseenter the way that
> >> mootools has it, I saw that the sweet prototype API has a Pointer
> >> class.
> >>
> >> I'm still a bit green with Prototype, but my answer came in this
> >> shape:
> >>
> >> Event.observe(nav, 'mouseout', function(e) {
> >>      if(!Position.within(nav,Event.pointerX(e),Event.pointerY(e))){
> >>              alert('...mouse is now truly outside nav...');
> >>              });
> >>      }
> >> });
> >>
> >> Have a good day!
> >> Sudara
> >>
> >>
> >>
> >
> >
> > >
> >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to