Skip to content

Commit a065bf1

Browse files
committed
Added global touchstart handler.
1 parent b8f7ecb commit a065bf1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/input/touch/TouchManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ var TouchManager = new Class({
174174
startListeners: function ()
175175
{
176176
var _this = this;
177+
var canvas = this.manager.canvas;
177178
var autoFocus = (window && window.focus && this.manager.game.config.autoFocus);
178179

179180
this.onTouchStart = function (event)
@@ -191,7 +192,7 @@ var TouchManager = new Class({
191192

192193
_this.manager.queueTouchStart(event);
193194

194-
if (_this.capture)
195+
if (_this.capture && event.target === canvas)
195196
{
196197
event.preventDefault();
197198
}
@@ -223,7 +224,7 @@ var TouchManager = new Class({
223224

224225
_this.manager.queueTouchEnd(event);
225226

226-
if (_this.capture)
227+
if (_this.capture && event.target === canvas)
227228
{
228229
event.preventDefault();
229230
}
@@ -286,6 +287,7 @@ var TouchManager = new Class({
286287

287288
if (window)
288289
{
290+
window.addEventListener('touchstart', this.onTouchStart, nonPassive);
289291
window.addEventListener('touchend', this.onTouchEnd, nonPassive);
290292
}
291293

@@ -312,6 +314,7 @@ var TouchManager = new Class({
312314

313315
if (window)
314316
{
317+
window.removeEventListener('touchstart', this.onTouchStart);
315318
window.removeEventListener('touchend', this.onTouchEnd);
316319
}
317320
},

0 commit comments

Comments
 (0)