0
我創建具有以下屬性的一個狀態消息欄:jQuery的狀態信息(到Twitter類似)
- 滑入視圖。一段時間後消失。
- 如果觸發了另一個狀態消息,則當前可見的狀態消息滑出視圖,然後新的狀態消息滑入視圖。
我遇到的問題是隨着淡出。淡出操作似乎沒有出列,因此之前的淡入操作將應用於隨後的狀態消息。任何想法如何解決這個問題?
function status_message(message, type, long_display) {
if (!type) {
type = SUCCESS;
}
var $status_message = $("#status_message");
long_display ? display_time = 9000 : display_time = 3250;
if ($status_message.is(":visible")) {
$status_message.queue("fx", []).animate({top:-$(this).outerHeight()}, 500, "easeInCubic");
}
$status_message.show().queue(function() {
$(this).html(message).css({'top': -$(this).outerHeight()}).addClass(type).dequeue();
}).animate({top:"0px"}, 750, easing).delay(display_time).fadeOut(500, function() {
$(this).animate({top:-$(this).outerHeight()}, 500, "easeInCubic").addClass(type);
});
}
function status_message_hide() {
$status_message.queue("fx", []).fadeOut(500, function() {
$(this).animate({top:-$(this).outerHeight()}, 500, "easeInCubic");
});
}
你有漸弱嘗試的setTimeout()?所以它總是在一定時間後開始? – justanotherhobbyist 2012-03-21 21:54:56