I'm going to do some performance testing today with synthetic events.
It probably makes sense to return an Event object that can use
functions to find all of these values instead of pre-calculating
everything and discarding what's not needed.
In your code, this is incorrect, layerX and offsetX are not equivalent:
result.offsetX = evnt.layerX || evnt.offsetX;
result.offsetY = evnt.layerY || evnt.offsetY;
See:
https://bugzilla.mozilla.org/show_bug.cgi?id=122665#c3
Mouse positioning has been the toughest problem for me. I've done a
lot of testing across browsers, I hope to post results on all of this
sometime today. Even Firefox, for instance, introduced an off-by-one
error for the layerX/Y properties from 1.0 to 1.5 (now fixed in trunk):
https://bugzilla.mozilla.org/show_bug.cgi?id=323843#c2
Also, this:
result.pageX = evnt.clientX + document.body.scrollLeft;
Should probably look more like this:
result.pageX = evnt.clientX +
(document.documentElement.scrollLeft ||
document.body.scrollLeft);
Though that may not be the final word, as IE's results are a couple
pixels out. I'll try to trim some of that fat out of the object I
return in Signal, but my goal for now is to make it consistently
correct.
Thanks!
On 18-Jan-06, at 6:32 AM, Ian MacLeod wrote:
Also note that I was toying around with the idea of type-specific
events (mouse, keyboard, etc), but it seems to be far more
efficient to just return an object that is identical for any type
of event.