Re: a minor confusion concerning mouse events

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.
You'll often only fire one of enter/leave on a given transition,
though.

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.

(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.)

~TJ

Received on Monday, 12 September 2011 08:47:04 UTC