W3C home > Mailing lists > Public > www-svg@w3.org > September 2011

Re: a minor confusion concerning mouse events

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Mon, 12 Sep 2011 07:22:53 -0700
Message-ID: <4E6E15BD.4020507@helsinki.fi>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: David Dailey <ddailey@zoominternet.net>, www-svg@w3.org
On 09/12/2011 01:46 AM, Tab Atkins Jr. wrote:
> On Sun, Sep 11, 2011 at 9:44 PM, Olli Pettay<Olli.Pettay@helsinki.fi>  wrote:
>> On 09/10/2011 09:49 AM, Tab Atkins Jr. wrote:
>>> IE exposes the much more useful (non-bubbling) mouseenter and
>>> mouseleave events,
>>
>> mouseenter/leave are perhaps useful, but easily quite slow, since they
>> need to be fired a lot more often.
>
> Hm, this doesn't make sense to me.  Ignoring any optimizations based
> on registration, it seems like enter/leave are still fired *less* than
> over/out.  over/out get fired on *every* transition between elements.
Right, when mouse moves from top of some element to top of some other
element, there is mouseout/mouseover

> You'll often only fire one of enter/leave on a given transition,
> though.

... but if the DOM is deeply nested, you need to fire mouseleave for
each element the mouse is "leaving" and for each element the mouse is
entering.



>
> One detail I'm not sure of without testing (which I can't do right now
> on this Linux laptop) is a situation like, for example, two elements
> each nested deeply in different branches, but placed next to each
> other.  Presumably mousing from one to the other would fire mouseleave
> events all the way up to their common node, and then mouseenter events
> all the way back down.  I'm not sure if mouseover/out would do the
> same or if they'd only fire once each.


there is only one mouseover/out, but several mouseenter/leave events.

>
> (In any case, I imagine that non-bubbling events are amenable to more
> aggressive registration-based pruning, right?  You can just keep a
> record of what nodes have listeners, and make a quick check before
> attempting to fire.)

You can optimize out some event dispatching when there are no
listeners, but if you for example have a capturing event listener in
window or document, your mouseenter/leave
listener would be called possibly a lot more often than
mouseout/over.




-Olli


>
> ~TJ
>
>
Received on Monday, 12 September 2011 14:23:25 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:49 GMT