can't overwrite the iOS event.scale and found a hole in 'has'
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {hypotenuse, noop} from './utils.js';
|
import {has, hypotenuse, noop} from './utils.js';
|
||||||
|
|
||||||
const MODULE = 'onTap';
|
const MODULE = 'onTap';
|
||||||
|
|
||||||
@@ -240,9 +240,10 @@ export default class OnTap {
|
|||||||
if (this.state.tapStartTime) {
|
if (this.state.tapStartTime) {
|
||||||
const touches = [...event.touches];
|
const touches = [...event.touches];
|
||||||
|
|
||||||
event.scale = event.scale ? event.scale :
|
if (!has(event, 'scale')) {
|
||||||
touches.length < 2 ? 1 :
|
event.scale = touches.length < 2 ? 1 :
|
||||||
hypotenuse(touches[0].pageX - touches[1].pageX, touches[0].pageY - touches[1].pageY) / this.state.scaleStart;
|
hypotenuse(touches[0].pageX - touches[1].pageX, touches[0].pageY - touches[1].pageY) / this.state.scaleStart;
|
||||||
|
}
|
||||||
|
|
||||||
Object.assign(event, {
|
Object.assign(event, {
|
||||||
offsetX: touches.reduce((memo, touch) => memo + touch.pageX, 0) / touches.length,
|
offsetX: touches.reduce((memo, touch) => memo + touch.pageX, 0) / touches.length,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function clone(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function has(obj, prop) {
|
export function has(obj, prop) {
|
||||||
return obj && obj.hasOwnProperty(prop);
|
return obj && (obj.hasOwnProperty(prop) || (prop in obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hypotenuse(a, b) {
|
export function hypotenuse(a, b) {
|
||||||
|
|||||||
Reference in New Issue
Block a user