Closed gkatsanos closed 9 years ago
Hi @gkatsanos! Thanks for asking. For your case, would you just be able to, in hoverIn
, just add a reference to the menu item as data on the dropdown content, use $.noop
for out
, and just register a listener for mouseleave
on the content? For example, something like this:
$('.menu-item[data-mlid]').hoverIntent({
over: hoverIn,
out: $.noop,
sensitivity: 1,
timeout: 200
});
function hoverIn() {
var activeitem = $(this).data('mlid');
$('.paddle-mega-dropdown[data-mlid="' + activeitem + '"]').fadeIn('fast');
}
// only handle mouseleave of content
$('.paddle-mega-dropdown').mouseleave(function(e) {
var activeitem = $(this).data('mlid');
var targetElement = e.relatedTarget;
if (! $(targetElement).closest('[data-mlid="' + activeitem + '"]').length) {
$('.paddle-mega-dropdown[data-mlid="' + activeitem + '"]').fadeOut('fast');
}
});
? Please let me know if this addresses your concern or if you've found another way already, and I will close the issue.
As I found a way to do this already, I close my issue. Many thanks.
@gkatsanos, interesting to see your solution.
I found a way to do this if anyone is still looking for a resolution. Basically you can use the $.noop jquery empty function for either the over or out function. Then you can just call hoverIntent as two different functions like this.
$("#main-navigation").hoverIntent( menuHoverOver, $.noop, 'li a' );
$("#main-navigation").hoverIntent( $.noop, menuHoverOut);
I have a mega drop-down menu, which doesn't follow the traditional HTML structure of dropdowns... (the dropdown is not a child of the
<li>
menu item.)Here's how my html looks like:
I don't know if you see the problem; I need to have an event handler on the "dropdow" class separately...
Now my code looks like:
but I guess that's not how the plugin is supposed to work..