From 83460bcdade28fe77908d3008444a23555f09487 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 4 Nov 2019 02:15:33 +0200 Subject: refactoring and optimization --- ext/fg/js/frontend.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ext/fg') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 84d6af28..b9410f2c 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -497,19 +497,21 @@ class Frontend { } static isMouseButton(button, mouseEvent) { - if (['mouseup', 'mousedown', 'click'].includes(mouseEvent.type)) { - switch (button) { + switch (mouseEvent.type) { + case 'mouseup': + case 'mousedown': + case 'click': switch (button) { case 'primary': return mouseEvent.button === 0; case 'secondary': return mouseEvent.button === 2; case 'auxiliary': return mouseEvent.button === 1; default: return false; } - } - switch (button) { - case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0; - case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0; - case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0; - default: return false; + default: switch (button) { + case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0; + case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0; + case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0; + default: return false; + } } } } -- cgit v1.2.3