Skip to content

Commit a8f98d4

Browse files
committed
Added MouseEvent.localX/Y
Signed-off-by: Grant Skinner <info@gskinner.com>
1 parent 4ab75e2 commit a8f98d4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

VERSIONS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Version NEXT [NOT RELEASED]
99
- fixed ColorMatrix.toArray(), .concat(), and .clone()
1010
- fixed touch/multitouch in IE11
1111
- changed dblclick to use a canvas listener instead of global listener
12+
- added MouseEvent.localX/Y
1213

1314

1415
Version 0.7.0 [September 25, 2013]

src/easeljs/events/MouseEvent.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,34 @@ var p = MouseEvent.prototype = new createjs.Event();
168168
p.hasEventListener = null;
169169
p._listeners = null;
170170
createjs.EventDispatcher.initialize(p); // inject EventDispatcher methods.
171+
172+
// getter / setters:
173+
/**
174+
* Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
175+
* @property localX
176+
* @type {Number}
177+
* @readonly
178+
*/
179+
p._get_localX = function() {
180+
return this.currentTarget.globalToLocal(this.rawX, this.rawY).x;
181+
};
182+
183+
/**
184+
* Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
185+
* @property localY
186+
* @type {Number}
187+
* @readonly
188+
*/
189+
p._get_localY = function() {
190+
return this.currentTarget.globalToLocal(this.rawX, this.rawY).y;
191+
};
192+
193+
try {
194+
Object.defineProperties(p, {
195+
localX: { get: p._get_localX },
196+
localY: { get: p._get_localY }
197+
});
198+
} catch (e) {} // TODO: use Log
171199

172200
// constructor:
173201
/**

0 commit comments

Comments
 (0)