2013-07-21 69 views
2

希望这不是一个重复的问题,我似乎无法找到答案。 这里是我的问题:等待悬停动画完成后再执行其他

我有一个悬停动画在jQuery中完成,我想如果用户悬停另一个链接,我想第一个动画做回调,并再次动画。

这里是我到目前为止已经有一个例子:http://sebastien-crapoulet.fr/test/

如果您有链接“的propos”,您将获得完整的动画,现在我要的是,如果你从“A去关于'提交'到'投资组合',而不是执行另一个悬停动画。

我用.stop()和.filter(':not(:animated)')弄错了,但未成功。

这里是我到目前为止有:提前任何帮助,您可以给

$('nav ul li a').hover(function(){ 
    link    = $(this) 
    color    = $(this).data("color") 
    position   = link.position(); 
    background   = $('.menuBackground') 

    if (color=="blue"){ 
     background.css({ 
      'background-color':'#99b3c4', 
      'width':(position.left)+(link.width())+20+'px', 
      'top':position.top+'px' 
     }) 
     background.stop().animate({ 
      left:'0%' 
     },500) 
    } 
    if (color=="green"){ 
     background.css({ 
      'background-color':'#91b6a5', 
      'width':(position.left)+(link.width())+20+'px', 
      'top':position.top+'px' 
     }) 
     background.stop().animate({ 
      left:'0%' 
     },500) 
    } 
    else { 
     return false; 
    } 
},function(){ 
    background.stop().animate({ 
     left:'-100%' 
    },500) 
    return false; 
}) 

谢谢!

回答

0

当用户将鼠标悬停在第一个元素上时,第二个元素关闭,第一个元素打开,反之亦然。