From a7d51d05433a4d45efc6baa926de9d3996f52291 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Tue, 1 Aug 2017 01:52:21 -0400 Subject: [PATCH] Fixes to click event, also effect color --- js/field.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/field.js b/js/field.js index c2d48c1..9f31333 100644 --- a/js/field.js +++ b/js/field.js @@ -33,7 +33,7 @@ var clickMaxDistInc = 5; var clickMaxDistMax = 5000; var clickPullRate = clickPullRateStart; var clickMaxDist = clickMaxDistStart; -var clickEndRebount = -20; +var clickEndRebount = -10; function randomInt (min, max) { // inclusive of min and max @@ -300,6 +300,7 @@ function pullPoints (points, clickPos, pullRate, maxDist) { if (Math.abs(xDist) <= maxDist && Math.abs(yDist) <= maxDist) { points.target[i][0] += Math.round(xDist * pullRate); points.target[i][1] += Math.round(yDist * pullRate); + points.target[i][3] = shiftColor(points.original[i][3], disconnectedColorShiftAmt * 3); } } } @@ -524,17 +525,25 @@ window.addEventListener('mouseup', function (e) { clickEnd = true; }); +window.addEventListener('mouseleave', function (e) { + clickEnd = true; +}); + window.addEventListener('touchstart', function (e) { - updateClickPos(e); + updateClickPos(e.changedTouches[0]); }); window.addEventListener('touchmove', function (e) { if (click !== null) { - updateClickPos(e); + updateClickPos(e.changedTouches[0]); } }); -window.addEventListener('touchup', function (e) { +window.addEventListener('touchend', function (e) { + clickEnd = true; +}); + +window.addEventListener('touchcancel', function (e) { clickEnd = true; });