Created
April 3, 2017 05:04
-
-
Save ka2n/7071c4e76be8395f0a448dc63b8efe1f 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
let t = 0 | |
const tapListener = e => { | |
let n = +new Date | |
if (n - t <= 500) { | |
e.preventDefault() | |
} | |
t = n | |
return false | |
} | |
export function disableDoubleTap() { | |
document.documentElement.addEventListener('touchend', tapListener, false) | |
} | |
export function enableDoubleTap() { | |
document.documentElement.removeEventListener('touchend', tapListener, false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment