Fix mobile touches can be empty.

Use changedTouches as backup
pull/6034/head
Berkeley Martinez 2016-01-09 22:47:28 -08:00
parent 2277cde61b
commit a681949995
1 changed files with 4 additions and 3 deletions

View File

@ -38,12 +38,13 @@ function findNextHike(hikes, id) {
function getMouse(e, [dx, dy]) {
let { pageX, pageY, touches } = e;
let { pageX, pageY, touches, changedTouches } = e;
if (touches) {
// touches can be empty on touchend
if (touches || changedTouches) {
e.preventDefault();
// these re-assigns the values of pageX, pageY from touches
({ pageX, pageY } = touches[0]);
({ pageX, pageY } = touches[0] || changedTouches[0]);
}
return [pageX - dx, pageY - dy];