Fix the bug which broke the swipe gesture in Safari.
I discovered it's a Safari bug, not restricted to mobile. Safari's TouchEvent is different from other browsers (see compatibility matrix...) so I had to figure out a different way to determine the source element of the event in Safari. I'm not sure if this is the best approach or not, but it appears to work as I can reproduce it locally and this fixes it. In addition, this approach should be more resilient to other failures in the future (e.g. I have no idea if it will work for IE), since it just uses try/catch. I'll feel better when we can test in production to be sure, it's harder to emulate swipe gestures on the iOS Simulator or in Safari.
Side note: Is there any way to get a Safari console for the iOS Simulator?
This PR:
I discovered it's a Safari bug, not restricted to mobile. Safari's
TouchEvent
is different from other browsers (see compatibility matrix...) so I had to figure out a different way to determine the source element of the event in Safari. I'm not sure if this is the best approach or not, but it appears to work as I can reproduce it locally and this fixes it. In addition, this approach should be more resilient to other failures in the future (e.g. I have no idea if it will work for IE), since it just usestry/catch
. I'll feel better when we can test in production to be sure, it's harder to emulate swipe gestures on the iOS Simulator or in Safari.Side note: Is there any way to get a Safari console for the iOS Simulator?