From b919a333e912a175b6b93f339663f5da5f699c2b Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Tue, 15 Nov 2016 22:16:48 -0800 Subject: [PATCH] More leniency when differentiating click/drag --- abp/static/scripts/mouse.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/abp/static/scripts/mouse.js b/abp/static/scripts/mouse.js index 880eab8..9f16ef4 100644 --- a/abp/static/scripts/mouse.js +++ b/abp/static/scripts/mouse.js @@ -1,6 +1,7 @@ var mouse = {}; mouse.wasClick = true; mouse.pressed = false; +mouse.leniency = 4; mouse.raycaster = new THREE.Raycaster(); @@ -30,6 +31,8 @@ mouse.prepare = function() { mouse.onDown = function(event) { mouse.wasClick = true; mouse.pressed = true; + mouse.startX = event.clientX; + mouse.startY = event.clientY; }; mouse.onUp = function(event) { @@ -48,7 +51,9 @@ mouse.onUp = function(event) { mouse.onMove = function(event) { // TODO: wasclick sux - mouse.wasClick = false; + if (Math.abs(event.clientX - mouse.startX)>mouse.leniency || Math.abs(event.clientY - mouse.startY)>mouse.leniency){ + mouse.wasClick = false; + } mouse.position_absolute = { x: event.clientX, y: event.clientY