How can I modify my plugin to work with hoverIntent if it is available?
I hav a plu开发者_Python百科gin that uses hover()
but it should use hoverIntent()
if it is available.
How would I do this with minimum fuss?
This will detect if hoverIntent has been included, and modify the hover
method to hoverIntent
in that case.
var bindMethod = $.isFunction(jQuery().hoverIntent) ? 'hoverIntent' : 'hover';
element[bindMethod](
function() {
// Mouse over
},
function() {
// Mouse out
});
You can then leave a note with your plugin that says...
- Compatible with hoverIntent.
精彩评论