Skip to content

Instantly share code, notes, and snippets.

@necojackarc
Last active March 5, 2018 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save necojackarc/d7ca48c61e5faa87bec48844f974987e to your computer and use it in GitHub Desktop.
Save necojackarc/d7ca48c61e5faa87bec48844f974987e to your computer and use it in GitHub Desktop.
function initialize() {
if (!is_ios()) return;
let document_click_on_ios;
document.addEventListener('touchstart', () => {
document_click_on_ios = true;
});
document.addEventListener('touchmove', () => {
// Don't regard it as a click event when the touched position moved
document_click_on_ios = false;
});
document.addEventListener('touchend', () => {
if (!document_click_on_ios) return;
// Write your onClick event handler
// console.log('document is clicked on iOS')
});
}
function is_ios () {
return navigator.userAgent && navigator.userAgent.match(/iPhone|iPad|iPod/);
}
initialize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment