1

我将 hoverIntent 与购物袋(#bagContainer)一起使用,一切正常。

function bagOver(){
    $(this).find("#bagContainer").stop().fadeTo('fast', 1).show(); 
}
function bagOut(){
  $(this).find("#bagContainer").stop().fadeTo('fast', 0, function() {
      $(this).hide();
  });
}
var bagHoverConfig = {
     over: bagOver,
     bagTimeout: 3000, 
     out: bagOut 
};
$("#userBox .row:nth-child(2)").hoverIntent(bagHoverConfig);

但我需要在包内添加一个“额外”关闭按钮(#bagCollapser),例如:

$("#bagCollapser").click(function () {
    $('#bagContainer').hide();
});

它关闭了#bagContainer,但似乎与hoverIntent有冲突:

  1. 该按钮隐藏了包,但是在 bagTimeout 之后, hoverIntent 再次隐藏了它
  2. 如果包已通过按钮关闭,则在 hoverIntent 的超时/延迟过去之前无法再次显示...

有任何想法吗?

提前非常感谢!

4

1 回答 1

0

我有同样的问题,我正在使用 hoverIntent 来显示 megamenu。在这个 megamenu 中,我创建了一个关闭按钮:

$("#closebutton").click(function () {
  $('#megasubmenu').hide();
  $('#megasubmenu').closest('li.level0').find('a.level0').removeClass("megahover");
});

关闭按钮关闭子菜单,但 hoverIntent 功能仍在运行,因为只要有鼠标移动,子菜单就会重新出现......

于 2017-03-21T15:08:47.927 回答