我有以下代码显示一个弹出窗口,然后在短时间内隐藏它:
div.stop()
.animate({top:'0px'},{queue:true,duration:this._speed})
.animate({opacity: 1.0}, {queue:true,duration:this._delay})
.animate({top:'-' + outer + 'px'},{queue:true,duration:this._speed,complete:this._myFunction});
动画完成后,函数 _myFunction 会正确触发,但是我看不到我的任何属性。
我想将一个名为 _showing 的属性设置为 false。
这是我的控件的一些更具描述性的代码:
MyCompany.WebNotify.prototype =
{
initialize : function()
{
// Call the base initialize method
MyCompany.WebNotify.callBaseMethod(this, 'initialize');
},
dispose : function()
{
// Clear the custom handlers
$clearHandlers(this.get_element());
// Call the base class method
MyCompany.WebNotify.callBaseMethod(this, 'dispose');
},
// Set/set the visible property
get_showing : function()
{
return this._showing;
},
set_showing : function(value)
{
var e = Function._validateParams(arguments, [{name: 'value', type: Boolean}]);
if (e) throw e;
if (this._showing != value)
{
this._updateShowing(value);
this.raisePropertyChanged('showing');
}
},
_updateShowing : function(value)
{
// Store the current value
this._showing = value;
var div = this._getMe();
var outer = parseInt(div.outerHeight());
if (value)
{
div.css("top", '-' + outer + 'px');
div.css("visibility","visible");
// If the delay is greater than 0, show, delay and then hide the notifier
if (this._delay > 0)
{
div.stop()
.animate({top:'0px'},{queue:true,duration:this._speed})
.animate({opacity: 1.0}, {queue:true,duration:this._delay})
.animate({top:'-' + outer + 'px'},{queue:true,duration:this._speed,complete:this._myFunction});
}
else
{
// Show the notifier and leave it displayed
div.stop().animate({top:'0px'},{queue:true,duration:this._speed});
}
}
else if (!this._notifyFirstRun)
{
// Hides the notifier
div.stop().animate({top:'-' + outer + 'px'},{queue:true,duration:this._speed});
}
this._notifyFirstRun = false;
},
_myFunction : function()
{
this._showing = false; // This isn't visibile, neither is get_showing, set_showing, or any functions
// All I see is the standard jQuery methods and properties.
},
_getMe : function()
{
return $("#" + this.get_id());
}
}
.animate 事件完成后如何更新 _showing 属性?