Skip to content

Commit

Permalink
Added handling of empty touchlist in touchend (which is the case for
Browse files Browse the repository at this point in the history
touch-emulation in chrome). Cache the most recent event and use that
instead.
  • Loading branch information
cdyk committed Jun 11, 2014
1 parent 6bab9a1 commit 8cda866
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/gui/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 8cda866

Please sign in to comment.