diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2019-11-04 02:15:33 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2019-11-04 02:15:33 +0200 |
commit | 83460bcdade28fe77908d3008444a23555f09487 (patch) | |
tree | c19dad44829da15addfa99f26fca110ab76355ed /ext/fg/js/frontend.js | |
parent | f4a987912a3bc7012cbfeaaa35ea94e5f97655e0 (diff) |
refactoring and optimization
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r-- | ext/fg/js/frontend.js | 18 |
1 files changed, 10 insertions, 8 deletions
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; + } } } } |