2011-04-10 114 views
1

我使用hoverIntent与购物袋(#bagContainer),并且一切正常。hoverIntent +关闭按钮(问题与超时?)

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的超时/延迟已经过去之前它不能再显示...

任何想法?

非常感谢!

回答

0

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

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

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