Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 14th, 2012  |  syntax: JavaScript  |  size: 1.20 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Q: I have a function, and want to animate a div element via css a transition (should look like a flipbox). How could i implement that the click function is not queued, so that you cannot "spam" the flipbox? Should there be a extra if statement or something similar?
  2.  
  3. JQUERY:
  4.  
  5. $(document).ready(function() {
  6.     function flipBack() {
  7.         console.log($(this));
  8.             var $this=$(this);
  9.             $this.removeClass('flip');
  10.             $this.children('.front').delay(600).show(0);
  11.             $this.children('.back').delay(600).hide(0);
  12.             return false;
  13.     }
  14.     function flipForward() {
  15.             var $this = $(this);
  16.             $this.addClass('flip');
  17.             $this.children('.front').delay(600).hide(0);
  18.             $this.children('.back').delay(600).show(0);
  19.         var t=setTimeout(function () {
  20.              $this.trigger("click");
  21.         },2000);
  22.     }    
  23.       $('.click').toggle(flipForward, flipBack);
  24.  
  25. });
  26.  
  27.  
  28. I tried to get things done with this, but i failed :)
  29.  
  30. $el.click(function(){
  31.     if( !clickban ){
  32.         clickban = true;
  33.         // Do something, and then afterwards set clickban to false
  34.         // and then you can click again.
  35.     }
  36. });