mjolnir.js
Advanced tools
Comparing version 2.7.1 to 2.7.3
@@ -119,4 +119,4 @@ "use strict"; | ||
case 'mousemove': | ||
// Move events use `which` to track the button being pressed | ||
if (event.which === 0) { | ||
// Move events use `bottons` to track the button being pressed | ||
if (event.buttons === 0) { | ||
// Button is not down | ||
@@ -123,0 +123,0 @@ this.pressed = false; |
@@ -16,6 +16,2 @@ "use strict"; | ||
}; | ||
// MouseEvent.which https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which | ||
var MOUSE_EVENT_WHICH_LEFT = 1; | ||
var MOUSE_EVENT_WHICH_MIDDLE = 2; | ||
var MOUSE_EVENT_WHICH_RIGHT = 3; | ||
// MouseEvent.button https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button | ||
@@ -38,16 +34,7 @@ var MOUSE_EVENT_BUTTON_LEFT = 0; | ||
} | ||
var _a = event.srcEvent, buttons = _a.buttons, button = _a.button, which = _a.which; | ||
var _a = event.srcEvent, buttons = _a.buttons, button = _a.button; | ||
var leftButton = false; | ||
var middleButton = false; | ||
var rightButton = false; | ||
if ( | ||
// button is up, need to find out which one was pressed before | ||
eventType === UP_EVENT || | ||
// moving but does not support `buttons` API | ||
(eventType === MOVE_EVENT && !Number.isFinite(buttons))) { | ||
leftButton = which === MOUSE_EVENT_WHICH_LEFT; | ||
middleButton = which === MOUSE_EVENT_WHICH_MIDDLE; | ||
rightButton = which === MOUSE_EVENT_WHICH_RIGHT; | ||
} | ||
else if (eventType === MOVE_EVENT) { | ||
if (eventType === MOVE_EVENT) { | ||
leftButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_LEFT_MASK); | ||
@@ -57,3 +44,3 @@ middleButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_MIDDLE_MASK); | ||
} | ||
else if (eventType === DOWN_EVENT) { | ||
else { | ||
leftButton = button === MOUSE_EVENT_BUTTON_LEFT; | ||
@@ -60,0 +47,0 @@ middleButton = button === MOUSE_EVENT_BUTTON_MIDDLE; |
@@ -56,3 +56,3 @@ "use strict"; | ||
} | ||
if (eventType & INPUT_MOVE && ev.which === 0) { | ||
if (eventType & INPUT_MOVE && ev.buttons === 0) { | ||
eventType = INPUT_END; | ||
@@ -59,0 +59,0 @@ } |
@@ -99,4 +99,4 @@ import Input from './input'; | ||
case 'mousemove': | ||
// Move events use `which` to track the button being pressed | ||
if (event.which === 0) { | ||
// Move events use `bottons` to track the button being pressed | ||
if (event.buttons === 0) { | ||
// Button is not down | ||
@@ -103,0 +103,0 @@ this.pressed = false; |
@@ -13,6 +13,2 @@ /* Constants */ | ||
}; | ||
// MouseEvent.which https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which | ||
const MOUSE_EVENT_WHICH_LEFT = 1; | ||
const MOUSE_EVENT_WHICH_MIDDLE = 2; | ||
const MOUSE_EVENT_WHICH_RIGHT = 3; | ||
// MouseEvent.button https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button | ||
@@ -35,16 +31,7 @@ const MOUSE_EVENT_BUTTON_LEFT = 0; | ||
} | ||
const { buttons, button, which } = event.srcEvent; | ||
const { buttons, button } = event.srcEvent; | ||
let leftButton = false; | ||
let middleButton = false; | ||
let rightButton = false; | ||
if ( | ||
// button is up, need to find out which one was pressed before | ||
eventType === UP_EVENT || | ||
// moving but does not support `buttons` API | ||
(eventType === MOVE_EVENT && !Number.isFinite(buttons))) { | ||
leftButton = which === MOUSE_EVENT_WHICH_LEFT; | ||
middleButton = which === MOUSE_EVENT_WHICH_MIDDLE; | ||
rightButton = which === MOUSE_EVENT_WHICH_RIGHT; | ||
} | ||
else if (eventType === MOVE_EVENT) { | ||
if (eventType === MOVE_EVENT) { | ||
leftButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_LEFT_MASK); | ||
@@ -54,3 +41,3 @@ middleButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_MIDDLE_MASK); | ||
} | ||
else if (eventType === DOWN_EVENT) { | ||
else { | ||
leftButton = button === MOUSE_EVENT_BUTTON_LEFT; | ||
@@ -57,0 +44,0 @@ middleButton = button === MOUSE_EVENT_BUTTON_MIDDLE; |
@@ -52,3 +52,3 @@ /** | ||
} | ||
if (eventType & INPUT_MOVE && ev.which === 0) { | ||
if (eventType & INPUT_MOVE && ev.buttons === 0) { | ||
eventType = INPUT_END; | ||
@@ -55,0 +55,0 @@ } |
{ | ||
"name": "mjolnir.js", | ||
"description": "An Event Manager", | ||
"version": "2.7.1", | ||
"version": "2.7.3", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "hammerjs", |
@@ -127,4 +127,4 @@ import type {MjolnirPointerEventRaw} from '../types'; | ||
case 'mousemove': | ||
// Move events use `which` to track the button being pressed | ||
if (event.which === 0) { | ||
// Move events use `bottons` to track the button being pressed | ||
if (event.buttons === 0) { | ||
// Button is not down | ||
@@ -131,0 +131,0 @@ this.pressed = false; |
@@ -16,6 +16,2 @@ import type {MjolnirEventRaw, HammerInput, Point} from '../types'; | ||
// MouseEvent.which https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which | ||
const MOUSE_EVENT_WHICH_LEFT = 1; | ||
const MOUSE_EVENT_WHICH_MIDDLE = 2; | ||
const MOUSE_EVENT_WHICH_RIGHT = 3; | ||
// MouseEvent.button https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button | ||
@@ -44,3 +40,3 @@ const MOUSE_EVENT_BUTTON_LEFT = 0; | ||
const {buttons, button, which} = event.srcEvent as PointerEvent; | ||
const {buttons, button} = event.srcEvent as PointerEvent; | ||
let leftButton = false; | ||
@@ -50,16 +46,7 @@ let middleButton = false; | ||
if ( | ||
// button is up, need to find out which one was pressed before | ||
eventType === UP_EVENT || | ||
// moving but does not support `buttons` API | ||
(eventType === MOVE_EVENT && !Number.isFinite(buttons)) | ||
) { | ||
leftButton = which === MOUSE_EVENT_WHICH_LEFT; | ||
middleButton = which === MOUSE_EVENT_WHICH_MIDDLE; | ||
rightButton = which === MOUSE_EVENT_WHICH_RIGHT; | ||
} else if (eventType === MOVE_EVENT) { | ||
if (eventType === MOVE_EVENT) { | ||
leftButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_LEFT_MASK); | ||
middleButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_MIDDLE_MASK); | ||
rightButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_RIGHT_MASK); | ||
} else if (eventType === DOWN_EVENT) { | ||
} else { | ||
leftButton = button === MOUSE_EVENT_BUTTON_LEFT; | ||
@@ -66,0 +53,0 @@ middleButton = button === MOUSE_EVENT_BUTTON_MIDDLE; |
@@ -61,3 +61,3 @@ /** | ||
if (eventType & INPUT_MOVE && ev.which === 0) { | ||
if (eventType & INPUT_MOVE && ev.buttons === 0) { | ||
eventType = INPUT_END; | ||
@@ -64,0 +64,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
232677
108
4641