Merge pull request #8729 from fredj/misc
Move functions out of the PointerEvent class
This commit is contained in:
@@ -69,12 +69,12 @@ class PointerEvent extends _Event {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.buttons = this.getButtons_(eventDict);
|
||||
this.buttons = getButtons(eventDict);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.pressure = this.getPressure_(eventDict, this.buttons);
|
||||
this.pressure = getPressure(eventDict, this.buttons);
|
||||
|
||||
// MouseEvent related properties
|
||||
|
||||
@@ -200,12 +200,14 @@ class PointerEvent extends _Event {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Object<string, ?>} eventDict The event dictionary.
|
||||
* @return {number} Button indicator.
|
||||
*/
|
||||
getButtons_(eventDict) {
|
||||
function getButtons(eventDict) {
|
||||
// According to the w3c spec,
|
||||
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
|
||||
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
|
||||
@@ -241,13 +243,13 @@ class PointerEvent extends _Event {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Object<string, ?>} eventDict The event dictionary.
|
||||
* @param {number} buttons Button indicator.
|
||||
* @return {number} The pressure.
|
||||
*/
|
||||
getPressure_(eventDict, buttons) {
|
||||
function getPressure(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
let pressure = 0;
|
||||
@@ -258,7 +260,6 @@ class PointerEvent extends _Event {
|
||||
}
|
||||
return pressure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user