2012-06-14 47 views
1

我有這個功能,我通過CSS動畫翻轉。我怎麼能實現點擊功能沒有排隊,所以你不能「垃圾」的翻蓋?jQuery無隊列

$(document).ready(function() { 
    function flipBack() { 
     console.log($(this)); 
     var $this = $(this); 
     $this.removeClass('flip'); 
     $this.children('.front').delay(600).show(0); 
     $this.children('.back').delay(600).hide(0); 
     return false; 
    } 

    function flipForward() { 
     var $this = $(this); 
     $this.addClass('flip'); 
     $this.children('.front').delay(600).hide(0); 
     $this.children('.back').delay(600).show(0); 
     var t = setTimeout(function() { 
      $this.trigger("click"); 
     }, 5000); 
    } 
    $('.click').toggle(flipForward, flipBack); 
}); 

任何想法都讚賞! Thnx提前!

回答

1

我通常使用一個名爲clickban的變量。

e.g:

$el.click(function(){ 
    if(!clickban){ 
     clickban = true; 
     // Do something, and then afterwards set clickban to false 
     // and then you can click again. 
    } 
}); 

你應該能夠適用於你的情況,我認爲!

希望能幫到:)