Skip to content

Instantly share code, notes, and snippets.

@pherrymason
Created April 11, 2014 11:06
Show Gist options
  • Save pherrymason/10458877 to your computer and use it in GitHub Desktop.
Save pherrymason/10458877 to your computer and use it in GitHub Desktop.
Unbind jQuery HoverIntent
var rawIntent = $.fn.hoverIntent;
$.fn.hoverIntent = function(handlerIn, handlerOut, selector){
var args = arguments;
return this.each(function(){
// If called with empty parameter list, disable hoverIntent
if( typeof handlerIn==='undefined' )
{
// Destroy the time if it is present
if( typeof(this.hoverIntent_t!=='undefined') )
{
this.hoverIntent_t = clearTimeout(this.hoverIntent_t);
}
// Cleanup all hoverIntent properties on the object
delete this.hoverIntent_t;
delete this.hoverIntent_s;
//Unbind all of the hoverIntent event handlers.
$(this).off('mousemove.hoverIntent,mouseenter.hoverIntent,mouseleave.hoverIntent');
}
else
{
rawIntent.apply( $(this), args);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment