diff --git a/CHANGELOG b/CHANGELOG index 8ae576b..ac7315b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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) diff --git a/src/dom/event.js b/src/dom/event.js index 89b6bf1..32d4d92 100644 --- a/src/dom/event.js +++ b/src/dom/event.js @@ -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)); + } /**