Merge pull request #8729 from fredj/misc

Move functions out of the PointerEvent class
This commit is contained in:
Frédéric Junod
2018-09-27 16:05:54 +02:00
committed by GitHub
+11 -10
View File
@@ -69,12 +69,12 @@ class PointerEvent extends _Event {
/** /**
* @type {number} * @type {number}
*/ */
this.buttons = this.getButtons_(eventDict); this.buttons = getButtons(eventDict);
/** /**
* @type {number} * @type {number}
*/ */
this.pressure = this.getPressure_(eventDict, this.buttons); this.pressure = getPressure(eventDict, this.buttons);
// MouseEvent related properties // MouseEvent related properties
@@ -200,12 +200,14 @@ class PointerEvent extends _Event {
} }
} }
/** }
* @private
/**
* @param {Object<string, ?>} eventDict The event dictionary. * @param {Object<string, ?>} eventDict The event dictionary.
* @return {number} Button indicator. * @return {number} Button indicator.
*/ */
getButtons_(eventDict) { function getButtons(eventDict) {
// According to the w3c spec, // According to the w3c spec,
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button // http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
// MouseEvent.button == 0 can mean either no mouse button depressed, or the // MouseEvent.button == 0 can mean either no mouse button depressed, or the
@@ -239,15 +241,15 @@ class PointerEvent extends _Event {
} }
} }
return buttons; return buttons;
} }
/**
* @private /**
* @param {Object<string, ?>} eventDict The event dictionary. * @param {Object<string, ?>} eventDict The event dictionary.
* @param {number} buttons Button indicator. * @param {number} buttons Button indicator.
* @return {number} The pressure. * @return {number} The pressure.
*/ */
getPressure_(eventDict, buttons) { function getPressure(eventDict, buttons) {
// Spec requires that pointers without pressure specified use 0.5 for down // Spec requires that pointers without pressure specified use 0.5 for down
// state and 0 for up state. // state and 0 for up state.
let pressure = 0; let pressure = 0;
@@ -257,7 +259,6 @@ class PointerEvent extends _Event {
pressure = buttons ? 0.5 : 0; pressure = buttons ? 0.5 : 0;
} }
return pressure; return pressure;
}
} }