2011-11-29 50 views
4

我正在使用jQuery的插件flip。我想翻转一张卡片(div),当它完成翻转后,立即恢复翻转它。这就是我试过的我需要翻转悬停的div

$("#flipbox").bind("hover",function(){ 
    $(this).flip({ 
     direction:'tb', 
     onEnd: function() { 
      $(this).revertFlip(); 
      console.log('when the animation has already ended'); 

     } 
    }) 
} 
+2

所以有什么问题了吗? –

+0

你可以尝试在jsfiddle上重新创建吗? –

+0

它翻转但不翻转,还是不翻转? – Qqwy

回答

0

试图作弊。 制作2个不同的课程,

然后使用mouseenter事件更改课程并将其更改回mouseleave事件。

至少,这就是那种东西我时,即时通讯接近我的最后期限:P

+0

我已经试过了mouseenter和mouseleave。这是行不通的。 –

1

试试这个:http://jsfiddle.net/netwire88/NAbZT/16/

$(document).on("click", ".flipbox-forward", function(e) { 
    e.preventDefault(); 
    var $this = $(this); 
    $this.flip({ 
     direction: $this.data("direction"), 
     color: $this.data("color"), 
     content: $this.data("title"), 
     onBefore: function() { 
      $this.removeClass('flipbox-forward'); 
      $this.addClass('flipbox-revert'); 
     } 
    }) 
}); 

$(document).on("click", ".flipbox-revert", function(e) { 
    e.preventDefault(); 
    var $this = $(this); 
    $this.revertFlip(); 
    $this.removeClass('flipbox-revert'); 
    $this.addClass('flipbox-forward'); 
});​