2015-06-20 60 views

回答

1

jQM爲此使用CSS轉換。對於翻轉,您可以使用名爲「.flip .in」的現有類翻轉並翻轉「.flip .out」以翻轉。

$('#target') 
    .append('<span>1. Append</span>') 
    .prepend('<span>2. Prepend</span>') 
    .before('<span>3. Before</span>') 
    .after('<span>4. After</span>') 
    .show() 
    .addClass("flip in") 
    .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 
     $(this).removeClass("flip in"); 
    }); 

您使用addClass添加過渡類(.addClass("flip in")),然後處理animationend事件刪除類時轉換完成。用翻轉來隱藏DIV:

$('#target') 
    .addClass("flip out") 
    .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 
     $(this).removeClass("flip out"); 
     $(this).hide(); 
    }); 

添加翻轉和出來的類,並在animationend上刪除類並調用hide()。

DEMO

注:欲瞭解更多有趣的轉變,您可以使用animate.css類似代碼:

https://daneden.github.io/animate.css/