2014-02-18 27 views
1

我使用Classie.JS創建s lideover menu demonstrated on Codrops使用Classie.js回撥

我使用的部分代碼如下。我想實現一個回調函數,以便該函數的最後兩行只有在切換完成後纔會出現(動畫)。謝謝!

showLeftOpen.onclick = function() { 
    classie.toggle(this, 'active'); 
    classie.toggle(menuLeft, 'cbp-spmenu-open'); 
    disableOther('showLeft'); 
    $('#showLeftOpen').hide(); 
    $('#showLeftClose').show(); 
}; 

回答

0
showLeftOpen.onclick = function() { 
    try { 
     classie.toggle(this, 'active'); 
     classie.toggle(menuLeft, 'cbp-spmenu-open'); 
     disableOther('showLeft'); 
    } finally { 
     $('#showLeftOpen').hide(); 
     $('#showLeftClose').show(); 
    } 
}; 
1

在try /終於沒有爲我工作,所以我只是使用的setTimeout()函數來達到預期的效果:

showLeftOpen.onclick = function() { 
    classie.toggle(this, 'active'); 
    classie.toggle(menuLeft, 'cbp-spmenu-open'); 
    disableOther('showLeft'); 
    setTimeout(function(){ 
       $('#showLeftOpen').hide(); 
       $('#showLeftClose').show(); 
    },200); 
};