Skip to content

Instantly share code, notes, and snippets.

@EddyVerbruggen
Created May 25, 2016 10:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EddyVerbruggen/70b96fce47fa7bf7a34f03e3a2ecb85f to your computer and use it in GitHub Desktop.
Save EddyVerbruggen/70b96fce47fa7bf7a34f03e3a2ecb85f to your computer and use it in GitHub Desktop.
// In case you embed a webview in a native app and the native app has a navigation bar you may find
// swiping up from the webview to the header (and releasing your finger on the header) will not fire
// a 'touchend' event on the webview.
//
// This code fixes it in a way where we listen for 'touchmove' events and fire a 'touchend' event
// programmatically in case the user leaves the webview at the top (negative Y coordinate):
document.addEventListener("touchmove", function(e) {
if (e.changedTouches[0].pageY < 0) {
e.preventDefault();
document.dispatchEvent(new Event('touchend'));
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment