我一直在試圖製作一個Dashboard Widget的div失蹤動畫,但它只是殘酷地變成「噗」(如在,只是瞬間消失,如預期的那樣)。動畫div失蹤,如何平滑?
function removeElement(elementId)
{
duration = 9000; // The length of the animation
interval = 13; // How often the animation should change
start = 1.0; // The starting value
finish = 0.0; // The finishing value
handler = function(animation, current, start, finish) {
// Called every interval; provides a current value between start and finish
document.getElementById(elementId).style.opacity = current;
};
new AppleAnimator(duration, interval, start, finish, handler).start();
interval = 1;
start= "visible";
finish = "hidden";
duration = 9001;
handler = function(animation, current, start, finish) {
document.getElementById(elementId).style.visibility="hidden";
};
new AppleAnimator(duration, interval, start, finish, handler).start();
}
我預計其不透明度達到零後「消失」在div毫秒,但對於一個不那麼明顯的原因(我),它只是立即消失。如果我註釋掉第二個動畫代碼,div淡出(但它仍然是活動的,我不想要)。
我還沒見過的所有解決方案都依賴於使用JQuery並在動畫結束後等待事件,除了JQuery之外,還有其他方法可以實現嗎?
好的,好的,它有幫助。 – frenchie 2012-03-01 18:01:22