javascript - Calling function after animation complete -


i have 2 functions open & close sidebar on page.

function closesidebar(functionafterclose) {         var functionafterclose = functionafterclose || function() {};         $("#sidebar").removeclass("open");         $("#sidebar").animate({marginleft: margin*-1},"fast", "swing", functionafterclose);         $("#dummy-column").animate({marginleft: margin*-1},"fast", "swing"); }  function opensidebar() {         $("#sidebar").addclass("open");         $("#sidebar").animate({marginleft:0},"fast", "swing");         $("#dummy-column").animate({marginleft:0},"fast", "swing"); } 

i'm trying pass function closesidebar() run after close animation complete. seems run straight away rather waiting sidebar animation complete.

closesidebar(function() {                 alert("function called");                 $(this).addclass("current");                 opensidebar();             }); 

what missing make function call once animation complete?

the jsfiddle - click button on right side, should animate in, call function, animate out again.

your javascript correct. problem in css. have transition set margin attribute. erase , js works fine.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -