From 1a470003fe6e0cea44ae431810380866a94835db Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Fri, 26 Nov 2021 10:27:43 -0800 Subject: [PATCH] fix: Stop throwing error when PointerEvent.pageX is 0. (#5727) The e.pageX (and .pageY) checks aren't strict enough. 0 is a perfectly valid coordinate. Checking for the existence of changedTouches is an easier way to distinguish a PointerEvent from a TouchEvent. --- core/touch_gesture.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/touch_gesture.js b/core/touch_gesture.js index 71634324b42..815da7c6392 100644 --- a/core/touch_gesture.js +++ b/core/touch_gesture.js @@ -323,8 +323,8 @@ TouchGesture.prototype.getTouchPoint = function(e) { return null; } return new Coordinate( - (e.pageX ? e.pageX : e.changedTouches[0].pageX), - (e.pageY ? e.pageY : e.changedTouches[0].pageY)); + (e.changedTouches ? e.changedTouches[0].pageX : e.pageX), + (e.changedTouches ? e.changedTouches[0].pageY : e.pageY)); }; exports.TouchGesture = TouchGesture;