can't overwrite the iOS event.scale and found a hole in 'has'

This commit is contained in:
Gavin McDonald
2018-09-24 21:44:33 -04:00
parent 9fc0ca46c5
commit 43339169c0
2 changed files with 6 additions and 5 deletions

View File

@@ -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 :
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,

View File

@@ -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) {