2013-08-05 58 views
0

如果你看看:http://www.wearewebstars.dk/frontend/Borneunivers/boerneunivers.html 并开始在左侧导航中点击左右,你会发现有时点击导航栏中的链接时,它会隐藏你来自的链接 - 有任何想法吗? 脚本我有,它是:leftnavigation animation does not fold in correcly

//Left navigation Animation 
      $(".left-navigation ul li").hover(function(){ 
       if($(this).hasClass('current')){ 

       } else { 
        $(this).animate({'width': '95%'}, 100, function() { 
         $(this).find("span.nav-text").delay(100).css("display", "inline-block"); 
        }); 
       } 
      }, function(){ 
       if($(this).hasClass('current')){ 

       } else { 
        $(this).animate({'width': '35px'}, 0, function() { 
         $(this).find("span.nav-text").css("display", "none"); 
        }); 
       } 
      }); 
+0

当您单击新的导航项目而不是悬停时,问题似乎就会发生。请在点击导航项目时提供相关的代码片段。 – Gloria

回答

0

你应该.stop()动画队列以中断附加动画建立:

http://jsbin.com/oxisal/1/

$(".left-navigation ul li:not(.current)").hover(function(e){ 

    var mEnt = e.type=="mouseenter"; // boolean true/false 

    $(this).stop().animate({width: mEnt?'95%':35}, mEnt?100:0, function() { 
     $(this).find("span.nav-text").css({ 
      display: mEnt? "inline-block" : "none" 
     }); 
    }); 

}); 

你应该.stop()也点击

0

我认为他们应该在.click中检查班级'current' t而不仅仅是在.hover事件中,否则如果你在另一个页面上去了prev的旧菜单按钮。页面保持选中状态,直到您将其悬停为止

相关问题