Created
September 15, 2013 01:26
-
-
Save plutochill/6567296 to your computer and use it in GitHub Desktop.
让鼠标经过事件和延时分离的出来,延时以及延迟的清除都已经由此方法解决了
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
(function($){ | |
$.fn.hoverDelay = function(options){ | |
var defaults = { | |
hoverDuring: 200, | |
outDuring: 200, | |
hoverEvent: function(){ | |
$.noop(); | |
}, | |
outEvent: function(){ | |
$.noop(); | |
} | |
}; | |
var sets = $.extend(defaults,options || {}); | |
var hoverTimer, outTimer; | |
return $(this).each(function(){ | |
$(this).hover(function(){ | |
clearTimeout(outTimer); | |
hoverTimer = setTimeout(sets.hoverEvent, sets.hoverDuring); | |
},function(){ | |
clearTimeout(hoverTimer); | |
outTimer = setTimeout(sets.outEvent, sets.outDuring); | |
}); | |
}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment