Skip to content

Instantly share code, notes, and snippets.

@higeorange
Created February 1, 2009 10:53
Show Gist options
  • Save higeorange/55848 to your computer and use it in GitHub Desktop.
Save higeorange/55848 to your computer and use it in GitHub Desktop.
(function($){
$.fn.eventDelay = function(delay, triger, cancel, callback) {
return this.each(function() {
var target = $(this);
var tid;
target.bind(triger, function(){
var self = this;
tid = setTimeout(function(){ callback.apply(self) }, delay * 1000)
})
target.bind(cancel, function(){
clearTimeout(tid)
})
});
}
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment