summaryrefslogtreecommitdiff
path: root/ext/mixed/js/dom.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 18:52:05 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 18:59:52 -0500
commit4110a848f5107c697e09c014d3488360fc8219ef (patch)
tree808696ac7328bbac23bec16434b0fe00806b6c23 /ext/mixed/js/dom.js
parent96aad50340b4d0374979ac981cd1c481cc8dcd94 (diff)
Move additional utility functions to DOM
Diffstat (limited to 'ext/mixed/js/dom.js')
-rw-r--r--ext/mixed/js/dom.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js
index 4525dace..4e4d49e3 100644
--- a/ext/mixed/js/dom.js
+++ b/ext/mixed/js/dom.js
@@ -43,4 +43,24 @@ class DOM {
}
return false;
}
+
+ static isMouseButtonPressed(mouseEvent, button) {
+ const mouseEventButton = mouseEvent.button;
+ switch (button) {
+ case 'primary': return mouseEventButton === 0;
+ case 'secondary': return mouseEventButton === 2;
+ case 'auxiliary': return mouseEventButton === 1;
+ default: return false;
+ }
+ }
+
+ static isMouseButtonDown(mouseEvent, button) {
+ const mouseEventButtons = mouseEvent.buttons;
+ switch (button) {
+ case 'primary': return (mouseEventButtons & 0x1) !== 0x0;
+ case 'secondary': return (mouseEventButtons & 0x2) !== 0x0;
+ case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0;
+ default: return false;
+ }
+ }
}