From 8105edca62d50e044151d77e16c7c017ad764b59 Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Wed, 25 Sep 2013 09:55:12 -0700 Subject: [PATCH] issue #606 moved evt.layerX/Y check at the end of the double pipe chain --- src/Stage.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Stage.js b/src/Stage.js index fab93490..eba4883a 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -576,9 +576,15 @@ } }, _setMousePosition: function(evt) { - - var mouseX = evt.offsetX !== undefined ? evt.offsetX : evt.layerX || (evt.clientX - this._getContentPosition().left), - mouseY = evt.offsetY !== undefined ? evt.offsetY : evt.layerY || (evt.clientY - this._getContentPosition().top); + var contentPosition = this._getContentPosition(), + mouseX = evt.offsetX + || ((evt.clientX || 0) - contentPosition.left) + || evt.layerX + || 0, + mouseY = evt.offsetY + || ((evt.clientY || 0) - contentPosition.top) + || evt.layerY + || 0; this.mousePos = { x: mouseX, @@ -586,15 +592,16 @@ }; }, _setTouchPosition: function(evt) { - var touch, touchX, touchY; + var contentPosition = this._getContentPosition(), + touch, touchX, touchY; if(evt.touches !== undefined && evt.touches.length === 1) { // one finger touch = evt.touches[0]; // get the information for finger #1 - touchX = touch.clientX - this._getContentPosition().left; - touchY = touch.clientY - this._getContentPosition().top; + touchX = touch.clientX - contentPosition.left; + touchY = touch.clientY - contentPosition.top; this.touchPos = { x: touchX,