Last active
March 5, 2018 03:43
-
-
Save necojackarc/d7ca48c61e5faa87bec48844f974987e 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
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