Jquery wait until all animation finish before starting new one -


i have menu slidedown/slideup animations attached hover event.

if hover on next menu position, while previous still animated slidedown, want wait slidedown finish , launch slideup current position.

i tried use promise object, not work @ all.

$('.menu-2>ul>li').each(function(){     $(this).hover(         function(){             var choice = $('ul', this);             ('.menu-2>ul>li>ul').promise().done(function(  ) {                 choice.slidedown();              });          },         function(){             $('ul', this).slideup(200);         }      ); }); 

you can add callback after slidedown finish. try example:

choice.slidedown("fast",function(){your function}) 

this call animation finish

update

$('.menu-2>ul>li').each(function(){     $(this).hover(         function(){             var choice = $('ul', this);             ('.menu-2>ul>li>ul').promise().done(function(  ) {                 choice.slidedown(500);              });          },         function(){             $('ul', this).delay(500).slideup(200);         }      ); }); 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -