Created
May 25, 2016 10:28
-
-
Save EddyVerbruggen/70b96fce47fa7bf7a34f03e3a2ecb85f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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