From 08a8f4f9d34ce56cbb3247608a72b274e4dd732c Mon Sep 17 00:00:00 2001 From: Pavel Dobryakov Date: Mon, 26 Aug 2019 02:36:01 +0200 Subject: [PATCH] fx --- script.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/script.js b/script.js index 70ebd37..765fa49 100644 --- a/script.js +++ b/script.js @@ -1006,20 +1006,13 @@ window.addEventListener('mouseup', function () { canvas.addEventListener('touchstart', function (e) { e.preventDefault(); var touches = e.targetTouches; - var loop = function ( i ) { - var touch = touches[i]; - var pointer = pointers.find(function (p) { return p.id == touch.identifier; }); - if (pointer == null) - { - pointer = new pointerPrototype(); - pointers.push(pointer); - } - var posX = scaleByPixelRatio(touch.pageX); - var posY = scaleByPixelRatio(touch.pageY); - updatePointerDownData(pointer, touch.identifier, posX, posY); - }; - - for (var i = 0; i < touches.length; i++) loop( i ); + for (var i = 0; i < touches.length; i++) { + if (i >= pointers.length) + { pointers.push(new pointerPrototype()); } + var posX = scaleByPixelRatio(touches[i].pageX); + var posY = scaleByPixelRatio(touches[i].pageY); + updatePointerDownData(pointers[i], touches[i].identifier, posX, posY); + } }); canvas.addEventListener('touchmove', function (e) {