Skip to content

Instantly share code, notes, and snippets.

@nuno
Forked from FokkeZB/singletap.js
Created August 15, 2014 13:42
Show Gist options
  • Save nuno/14ff93c46a53d83a7579 to your computer and use it in GitHub Desktop.
Save nuno/14ff93c46a53d83a7579 to your computer and use it in GitHub Desktop.
Snippet from Blain Hamon on how to prevent Titanium from queing up multiple tap events
function handleOnce(funct) {
var flag = false;
return function(e) {
if (flag) return;
flag = true;
setTimeout(function() {
flag = false;
}, 0);
funct(e);
};
}
// Usage is done as:
win.addEventListener('foo', handleOnce(
function(e){
alert('I dont queue');
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment