[Seaside] Detecting when mouse goes out of a div (I mean really out)

Lukas Renggli renggli at gmail.com
Sat Aug 4 07:16:16 UTC 2007


I have been using onMouseOver and onMouseOut in several projects and
these events mostly worked for me as expected. I would rather prefer
to call these events onMouseEnter and onMouseExit, but anyway.

>     I imagine that you also found awsome the DOM "feature" that client
> agents decided to implement in which you receiver #mouseout events
> even when the mouse goes more deep *inside* that div (sub elements).

This is because your sub-elements also trigger the event and the it
bubbles upwards in the DOM tree (unless you cancel it). To avoid that
you have to manually check in the event object if this is the right
element to handle. For details see:

http://www.quirksmode.org/js/events_mouse.html#mouseover

>     I was able to implement some js wrappers to manage that but I'm not
> *that* satisfied with the results (mainly because js VMs being so slow
> todays and having such *pieces* of garbage collectors among other wonders).

What do you exactly do that it is so slow? Event handlers should be
reasonably short to avoid the whole system getting slow.

>     So I wnated to ask how other seasiders have managed to detect the case
> in which the pointer in fact goes out an element's surface. One typical
> application for this is making a menu to collapse when pointer get out it's
> surface (and no submenu open). Did you managed a case like this?

You can do that also with pure CSS. For example:

http://www.alistapart.com/articles/horizdropdowns
http://www.tanfa.co.uk/css/examples/menu
http://www.cssplay.co.uk/menus/final_drop.html

Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch


More information about the Seaside mailing list