Last active
June 5, 2019 13:33
-
-
Save AndersDJohnson/4200108 to your computer and use it in GitHub Desktop.
eat touchend on links
This file contains hidden or 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
| // Wrangling with "ghost clicks" in Sencha Touch... is this hungry enough to eat them? | |
| // Based on http://stackoverflow.com/questions/6457220/sencha-touch-button-handler-called-twice-for-single-click-why | |
| // Put this somewhere global and early. (top of app.js?) | |
| document.addEventListener('touchend', function(e) { | |
| var node = e.target; | |
| while (node) { | |
| if ( | |
| (node.localName && node.localName.toLowerCase && node.localName.toLowerCase() === 'a') || | |
| (node.tagName && node.tagName.toLowerCase && node.tagName.toLowerCase() === 'a') | |
| ) { | |
| if (typeof e.preventDefault === 'function') e.preventDefault(); | |
| if (typeof e.stopPropagation === 'function') e.stopPropagation(); | |
| if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation(); | |
| return false; | |
| } | |
| node = node.parentNode; | |
| } | |
| }, true); // could also try with useCapture of false instead of true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment