From 8cda866622c07a81b2e56da3d08d0864761698d7 Mon Sep 17 00:00:00 2001 From: Christopher Dyken Date: Wed, 11 Jun 2014 20:17:30 +0200 Subject: [PATCH] Added handling of empty touchlist in touchend (which is the case for touch-emulation in chrome). Cache the most recent event and use that instead. --- js/gui/Canvas.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/gui/Canvas.js b/js/gui/Canvas.js index 36ac2fc..8180e93 100644 --- a/js/gui/Canvas.js +++ b/js/gui/Canvas.js @@ -256,6 +256,7 @@ dojo.declare("gui.Canvas", [dijit._Widget], { _touchstart: function (event) { this._active = true; + this._touch_prev = event; // We need to add the relative placement informatoin to all touch events for(var i = 0; i < event.touches.length; ++i) { @@ -280,6 +281,11 @@ dojo.declare("gui.Canvas", [dijit._Widget], { _touchend: function (event) { this._active = false; + if( event.touches.length == 0 ) { + // Use last active position + event = this._touch_prev; + } + for(var i = 0; i < event.touches.length; ++i) { var x = event.touches[i].pageX - this._placementX(); var y = event.touches[i].pageY - this._placementY(); @@ -303,6 +309,7 @@ dojo.declare("gui.Canvas", [dijit._Widget], { }, _touchmove: function (event) { + this._touch_prev = event; for(var i = 0; i < event.touches.length; ++i) { var x = event.touches[i].pageX - this._placementX(); var y = event.touches[i].pageY - this._placementY();