Reverse the definitions of Event#pointer(X|Y) and Event#pointer to prevent unnecessary computation. [#403 state:resolved] (Nick Stakenburg, Andrew Dupont).

This commit is contained in:
Andrew Dupont 2009-02-28 12:16:12 -06:00
parent 9d7a981e4c
commit 4a0b9b7c1d
2 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,5 @@
* Reverse the definitions of Event#pointer(X|Y) and Event#pointer to prevent unnecessary computation. [#403 state:resolved] (Nick Stakenburg, Andrew Dupont).
* Add first-class support for `mouseenter` and `mouseleave` events in non-IE browsers (IE supports them natively). [#350 state:resolved] (Nick Stakenburg, Andrew Dupont)
* Make sure `_extendedByPrototype`, `_countedByPrototype`, and `prototypeUID` node expandos are accessed with `typeof` to prevent errors in some environments. [#354 state:resolved] (Hilberty, kangax, Andrew Dupont)

View File

@ -131,16 +131,7 @@
* _viewport_.
**/
function pointer(event) {
var docElement = document.documentElement,
body = document.body || { scrollLeft: 0, scrollTop: 0 };
return {
x: event.pageX || (event.clientX +
(docElement.scrollLeft || body.scrollLeft) -
(docElement.clientLeft || 0)),
y: event.pageY || (event.clientY +
(docElement.scrollTop || body.scrollTop) -
(docElement.clientTop || 0))
};
return { x: pointerX(event), y: pointerY(event) };
}
/**
@ -152,7 +143,14 @@
* Note that this position is absolute on the _page_, not on the
* _viewport_.
**/
function pointerX(event) { return Event.pointer(event).x }
function pointerX(event) {
var docElement = document.documentElement,
body = document.body || { scrollLeft: 0 };
return event.pageX || (event.clientX +
(docElement.scrollLeft || body.scrollLeft) -
(docElement.clientLeft || 0));
}
/**
* Event.pointerY(event) -> Number
@ -163,7 +161,14 @@
* Note that this position is absolute on the _page_, not on the
* _viewport_.
**/
function pointerY(event) { return Event.pointer(event).y }
function pointerY(event) {
var docElement = document.documentElement,
body = document.body || { scrollTop: 0 };
return event.pageY || (event.clientY +
(docElement.scrollTop || body.scrollTop) -
(docElement.clientTop || 0));
}
/**