Skip to content

Commit

Permalink
fix: Stop throwing error when PointerEvent.pageX is 0. (google#5727)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NeilFraser authored Nov 26, 2021
1 parent da3df70 commit 1a47000
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/touch_gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 1a47000

Please sign in to comment.