欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery重新播放css動畫所遇問題解決

 更新時(shí)間:2013年08月21日 19:14:27   作者:  
做css動畫,遇到需要用腳本重新播放動畫的情況,下面與大家分享下,感興趣的朋友可以參考下,希望對大家有所幫助
最近在做css動畫,遇到需要用腳本重新播放動畫的情況。例如:

css動畫代碼
復(fù)制代碼 代碼如下:

.seed_txt_out .seed_txt h2 {
animation-name: seed-h2;
animation-duration: 2s;
animation-timing-function: ease;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: alternate;
animation-play-state: running;
position: relative;
top: 10px;
}
@keyframes seed-h2
{
from {top: -120px;}
to {top: 10px;}
}

jquery調(diào)用播放
復(fù)制代碼 代碼如下:

$(".seed_txt_out").children("div").removeClass("seed_txt");
$(".seed_txt_out").children("div").addClass("seed_txt");

這時(shí)候,會發(fā)現(xiàn),第一次顯示,動畫會正確播放,但是,第二次的時(shí)候,動畫就不會播放了。

后來上網(wǎng)查了一下,解決辦法很簡單,復(fù)制一個(gè)元素,把原來的去掉,在新的上面添加式樣就可以了。
復(fù)制代碼 代碼如下:

$(opts.txt).children("div").removeClass("seed_txt");
temp = $(opts.txt).children("div:eq(" + $(this).parent("ul").children("li").index(this) + ")");
newDiv = temp.clone(true);
temp.after(newDiv);
temp.remove();
newDiv.addClass("seed_txt");

這里有個(gè)鏈接,老外解決的辦法。還說了其它情況。遇到類似問題的朋友可以參考下,當(dāng)然,是英文的。
http://css-tricks.com/restart-css-animation/

相關(guān)文章

最新評論