diff --git a/src/onTap.js b/src/onTap.js index cd41eca..8ff9ba2 100644 --- a/src/onTap.js +++ b/src/onTap.js @@ -1,4 +1,4 @@ -import {hypotenuse, noop} from './utils.js'; +import {has, hypotenuse, noop} from './utils.js'; const MODULE = 'onTap'; @@ -240,9 +240,10 @@ export default class OnTap { if (this.state.tapStartTime) { const touches = [...event.touches]; - event.scale = event.scale ? event.scale : - touches.length < 2 ? 1 : - hypotenuse(touches[0].pageX - touches[1].pageX, touches[0].pageY - touches[1].pageY) / this.state.scaleStart; + if (!has(event, 'scale')) { + event.scale = touches.length < 2 ? 1 : + hypotenuse(touches[0].pageX - touches[1].pageX, touches[0].pageY - touches[1].pageY) / this.state.scaleStart; + } Object.assign(event, { offsetX: touches.reduce((memo, touch) => memo + touch.pageX, 0) / touches.length, diff --git a/src/utils.js b/src/utils.js index 1f461eb..fbb57a3 100644 --- a/src/utils.js +++ b/src/utils.js @@ -34,7 +34,7 @@ export function clone(obj) { } export function has(obj, prop) { - return obj && obj.hasOwnProperty(prop); + return obj && (obj.hasOwnProperty(prop) || (prop in obj)); } export function hypotenuse(a, b) {