diff --git a/packages/interaction/src/InteractionData.js b/packages/interaction/src/InteractionData.js index 992376b..e41df68 100644 --- a/packages/interaction/src/InteractionData.js +++ b/packages/interaction/src/InteractionData.js @@ -164,9 +164,8 @@ * Copies properties from normalized event data. * * @param {Touch|MouseEvent|PointerEvent} event The normalized event data - * @private */ - _copyEvent(event) + copyEvent(event) { // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite // it with "false" on later events when our shim for it on touch events might not be @@ -176,7 +175,9 @@ this.isPrimary = true; } this.button = event.button; - this.buttons = event.buttons; + // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard + // event.which property instead, which conveys the same information. + this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which; this.width = event.width; this.height = event.height; this.tiltX = event.tiltX; @@ -190,10 +191,8 @@ /** * Resets the data for pooling. - * - * @private */ - _reset() + reset() { // isPrimary is the only property that we really need to reset - everything else is // guaranteed to be overwritten diff --git a/packages/interaction/src/InteractionData.js b/packages/interaction/src/InteractionData.js index 992376b..e41df68 100644 --- a/packages/interaction/src/InteractionData.js +++ b/packages/interaction/src/InteractionData.js @@ -164,9 +164,8 @@ * Copies properties from normalized event data. * * @param {Touch|MouseEvent|PointerEvent} event The normalized event data - * @private */ - _copyEvent(event) + copyEvent(event) { // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite // it with "false" on later events when our shim for it on touch events might not be @@ -176,7 +175,9 @@ this.isPrimary = true; } this.button = event.button; - this.buttons = event.buttons; + // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard + // event.which property instead, which conveys the same information. + this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which; this.width = event.width; this.height = event.height; this.tiltX = event.tiltX; @@ -190,10 +191,8 @@ /** * Resets the data for pooling. - * - * @private */ - _reset() + reset() { // isPrimary is the only property that we really need to reset - everything else is // guaranteed to be overwritten diff --git a/packages/interaction/src/InteractionEvent.js b/packages/interaction/src/InteractionEvent.js index 5dab953..c0bf491 100644 --- a/packages/interaction/src/InteractionEvent.js +++ b/packages/interaction/src/InteractionEvent.js @@ -58,11 +58,9 @@ } /** - * Prevents event from reaching any objects other than the current object. - * - * @private + * Resets the event. */ - _reset() + reset() { this.stopped = false; this.currentTarget = null; diff --git a/packages/interaction/src/InteractionData.js b/packages/interaction/src/InteractionData.js index 992376b..e41df68 100644 --- a/packages/interaction/src/InteractionData.js +++ b/packages/interaction/src/InteractionData.js @@ -164,9 +164,8 @@ * Copies properties from normalized event data. * * @param {Touch|MouseEvent|PointerEvent} event The normalized event data - * @private */ - _copyEvent(event) + copyEvent(event) { // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite // it with "false" on later events when our shim for it on touch events might not be @@ -176,7 +175,9 @@ this.isPrimary = true; } this.button = event.button; - this.buttons = event.buttons; + // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard + // event.which property instead, which conveys the same information. + this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which; this.width = event.width; this.height = event.height; this.tiltX = event.tiltX; @@ -190,10 +191,8 @@ /** * Resets the data for pooling. - * - * @private */ - _reset() + reset() { // isPrimary is the only property that we really need to reset - everything else is // guaranteed to be overwritten diff --git a/packages/interaction/src/InteractionEvent.js b/packages/interaction/src/InteractionEvent.js index 5dab953..c0bf491 100644 --- a/packages/interaction/src/InteractionEvent.js +++ b/packages/interaction/src/InteractionEvent.js @@ -58,11 +58,9 @@ } /** - * Prevents event from reaching any objects other than the current object. - * - * @private + * Resets the event. */ - _reset() + reset() { this.stopped = false; this.currentTarget = null; diff --git a/packages/interaction/src/InteractionManager.js b/packages/interaction/src/InteractionManager.js index c5691a8..e100f00 100644 --- a/packages/interaction/src/InteractionManager.js +++ b/packages/interaction/src/InteractionManager.js @@ -1664,7 +1664,7 @@ } // copy properties from the event, so that we can make sure that touch/pointer specific // data is available - interactionData._copyEvent(event); + interactionData.copyEvent(event); return interactionData; } @@ -1682,7 +1682,7 @@ if (interactionData) { delete this.activeInteractionData[pointerId]; - interactionData._reset(); + interactionData.reset(); this.interactionDataPool.push(interactionData); } } @@ -1720,7 +1720,7 @@ } interactionData.originalEvent = pointerEvent; - interactionEvent._reset(); + interactionEvent.reset(); return interactionEvent; }