diff --git a/src/interaction/InteractionData.js b/src/interaction/InteractionData.js index e40be15..23f3dad 100644 --- a/src/interaction/InteractionData.js +++ b/src/interaction/InteractionData.js @@ -38,12 +38,13 @@ * * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off * @param [point] {Point} A Point object in which to store the value, optional (otherwise will create a new point) + * param [globalPos] {Point} A Point object containing your custom global coords, optional (otherwise will use the current global coords) * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject */ -InteractionData.prototype.getLocalPosition = function (displayObject, point) +InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) { var worldTransform = displayObject.worldTransform; - var global = this.global; + var global = globalPos ? globalPos : this.global; // do a cheeky transform to get the mouse coords; var a00 = worldTransform.a, a01 = worldTransform.c, a02 = worldTransform.tx, diff --git a/src/interaction/InteractionData.js b/src/interaction/InteractionData.js index e40be15..23f3dad 100644 --- a/src/interaction/InteractionData.js +++ b/src/interaction/InteractionData.js @@ -38,12 +38,13 @@ * * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off * @param [point] {Point} A Point object in which to store the value, optional (otherwise will create a new point) + * param [globalPos] {Point} A Point object containing your custom global coords, optional (otherwise will use the current global coords) * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject */ -InteractionData.prototype.getLocalPosition = function (displayObject, point) +InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) { var worldTransform = displayObject.worldTransform; - var global = this.global; + var global = globalPos ? globalPos : this.global; // do a cheeky transform to get the mouse coords; var a00 = worldTransform.a, a01 = worldTransform.c, a02 = worldTransform.tx, diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index 875b1fd..6874701 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -616,8 +616,9 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; - for (var i=0; i < changedTouches.length; i++) + for (var i=0; i < cLength; i++) { var touchEvent = changedTouches[i]; //TODO POOL @@ -665,10 +666,11 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; - for (var i=0; i < changedTouches.length; i++) + for (var i=0; i < cLength; i++) { - var touchEvent = changedTouches[i]; + touchEvent = changedTouches[i]; var touchData = this.getTouchData( touchEvent ); @@ -728,10 +730,11 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; - for (var i=0; i < changedTouches.length; i++) + for (var i=0; i < cLength; i++) { - var touchEvent = changedTouches[i]; + touchEvent = changedTouches[i]; var touchData = this.getTouchData( touchEvent ); @@ -778,6 +781,9 @@ touchData.identifier = touchEvent.identifier; this.mapPositionToPoint( touchData.global, touchEvent.clientX, touchEvent.clientY ); + touchEvent.globalX = touchData.global.x; + touchEvent.globalY = touchData.global.y; + return touchData; };