Unintuitive removeClass() problem

后端 未结 3 1989
无人及你
无人及你 2021-01-25 20:42

I\'m using this flip plugin, see the code in this fiddle. The goal is to flip one box at a time, e.g. the second box clicked should revertFlip() the previous one.

3条回答
  •  爱一瞬间的悲伤
    2021-01-25 21:09

    Can you try this script

    var $prevFlip;
    $('.flippable:not(.reverted)').live('click',function()     {         
        var $this = $(this);         
        var $allBoxes = $('.flippable');                
        $this.flip(         {             
            direction: 'lr',             
            color: '#82BD2E',             
            content: 'now flipped',             
            onBefore: function()             {           
                if($prevFlip){
                    $prevFlip.revertFlip();                 
                    $prevFlip.removeClass('reverted');              
                }
            },             
            onAnimation: function ()              {                  
                //$allBoxes.preventDefault();             
                //This is not a valid line
            },             
            onEnd: function()             {                  
                $this.addClass('reverted');      
                $prevFlip = $this;
            }          
        });    
        return false;     
    });
    

    This reverts only one previous item. This is not a complete solution. I think there are more problems to this. I'll post any further updates if I found them.

    I think @Andrew got the answer you are looking for.

提交回复
热议问题