Mouse button modifier update (#824)

* Ensure buttons is positive before adding to set

* Break early when there are no flags remaining
This commit is contained in:
toasted-nutbread 2020-09-13 13:43:38 -04:00 committed by GitHub
parent 621aa354e7
commit d7c3c87d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,12 +312,14 @@ class DocumentUtil {
}
static _getActiveButtons(event, set) {
const {buttons} = event;
if (typeof buttons === 'number') {
let {buttons} = event;
if (typeof buttons === 'number' && buttons > 0) {
for (let i = 0; i < 6; ++i) {
const buttonFlag = (1 << i);
if ((buttons & buttonFlag) !== 0) {
set.add(`mouse${i}`);
buttons &= ~buttonFlag;
if (buttons === 0) { break; }
}
}
}