【发布时间】:2012-03-21 21:46:26
【问题描述】:
我正在创建一个具有以下属性的状态消息栏:
- 滑入视野。一段时间后消失。
- 如果触发了另一条状态消息,当前可见的状态消息会滑出视图,然后新的状态消息会滑入视图。
我遇到的问题是淡出。淡出动作似乎没有出队,因此先前的淡出将应用于随后的状态消息。知道如何解决这个问题吗?
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() 吗?所以它总是在一定时间后开始?
标签: javascript jquery jquery-ui animation