我創建了一個元素,當點擊時改變狀態,但是我希望它通過特定的動畫過渡到該狀態。初學jQuery自定義動畫
我已經設法實現了自定義動畫,但動畫完成後,它會一直恢復到原始狀態。
這裏就是我的意思是:http://codepen.io/FlyingEmu/pen/vEyLd
關於如何解決此問題的任何想法?
JS代碼:
$(document).ready(function() {
var CardFront = true;
$('.card').click(function() {
if (CardFront == true) {
CardFront = false;
$('#card1').css("animation", "Fly_Out 1s");
$('#card2').css("animation", "Fly_Out 1s 0.1s");
$('#card3').css("animation", "Fly_Out 1s 0.2s");
$('#card4').css("animation", "Fly_Out 1s 0.3s");
}
else {
CardFront = true;
$('#card1').css("animation", "Fly_In 1s");
$('#card2').css("animation", "Fly_In 1s 0.1s");
$('#card3').css("animation", "Fly_In 1s 0.2s");
$('#card4').css("animation", "Fly_In 1s 0.3s");
}
});
});
請張貼您的代碼。 -1 – Doorknob