📄 animations.js
字号:
/// </summary>
/// <param name="owner" type="AjaxControlToolkit.Animation.Animation">
/// Parent animation
/// </param>
/// <returns />
this._owner = owner;
},
raiseStarted : function() {
/// <summary>
/// Raise the <code>started</code> event
/// </summary>
/// <returns />
var handlers = this.get_events().getHandler('started');
if (handlers) {
handlers(this, Sys.EventArgs.Empty);
}
},
add_started : function(handler) {
/// <summary>
/// Adds an event handler for the <code>started</code> event.
/// </summary>
/// <param name="handler" type="Function">
/// The handler to add to the event.
/// </param>
/// <returns />
this.get_events().addHandler("started", handler);
},
remove_started : function(handler) {
/// <summary>
/// Removes an event handler for the <code>started</code> event.
/// </summary>
/// <param name="handler" type="Function">
/// The handler to remove from the event.
/// </param>
/// <returns />
this.get_events().removeHandler("started", handler);
},
raiseEnded : function() {
/// <summary>
/// Raise the <code>ended</code> event
/// </summary>
/// <returns />
var handlers = this.get_events().getHandler('ended');
if (handlers) {
handlers(this, Sys.EventArgs.Empty);
}
},
add_ended : function(handler) {
/// <summary>
/// Adds an event handler for the <code>ended</code> event.
/// </summary>
/// <param name="handler" type="Function">
/// The handler to add to the event.
/// </param>
/// <returns />
this.get_events().addHandler("ended", handler);
},
remove_ended : function(handler) {
/// <summary>
/// Removes an event handler for the <code>ended</code> event.
/// </summary>
/// <param name="handler" type="Function">
/// The handler to remove from the event.
/// </param>
/// <returns />
this.get_events().removeHandler("ended", handler);
},
get_target : function() {
/// <value type="Sys.UI.DomElement" domElement="true" mayBeNull="true">
/// Target of the animation. If the target of this animation is null and
/// the animation has a parent, then it will recursively use the target of
/// the parent animation instead.
/// </value>
/// <remarks>
/// Do not set this property in a generic Xml animation description. It should be set
/// using either the extender's TargetControlID or the AnimationTarget property (the latter
/// maps to AjaxControlToolkit.Animation.set_animationTarget). The only valid way to
/// set this property in the generic Xml animation description is to use the dynamic
/// property TargetScript="$get('myElement')".
/// <remarks>
if (!this._target && this._parentAnimation) {
return this._parentAnimation.get_target();
}
return this._target;
},
set_target : function(value) {
if (this._target != value) {
this._target = value;
this.raisePropertyChanged('target');
}
},
set_animationTarget : function(id) {
/// <value type="string" mayBeNull="false">
/// ID of a Sys.UI.DomElement or Sys.UI.Control to use as the target of the animation
/// </value>
/// <remarks>
/// If no Sys.UI.DomElement or Sys.UI.Control can be found for the given ID, an
/// argument exception will be thrown.
/// <remarks>
// Try to find a Sys.UI.DomElement
var target = null;
var element = $get(id);
if (element) {
target = element;
} else {
// Try to find the control in the AJAX controls collection
var ctrl = $find(id);
if (ctrl) {
element = ctrl.get_element();
if (element) {
target = element;
}
}
}
// Use the new target if we have one, or raise an error if not
if (target) {
this.set_target(target);
} else {
throw Error.argument('id', String.format(AjaxControlToolkit.Resources.Animation_TargetNotFound, id));
}
},
get_duration : function() {
/// <value type="Number">
/// Length of the animation in seconds. The default is 1.
/// </value>
return this._duration;
},
set_duration : function(value) {
value = this._getFloat(value);
if (this._duration != value) {
this._duration = value;
this.raisePropertyChanged('duration');
}
},
get_fps : function() {
/// <value type="Number" integer="true">
/// Number of steps per second. The default is 25.
/// </value>
return this._fps;
},
set_fps : function(value) {
value = this._getInteger(value);
if (this.fps != value) {
this._fps = value;
this.raisePropertyChanged('fps');
}
},
get_isActive : function() {
/// <value type="Boolean">
/// <code>true</code> if animation is active, <code>false</code> if not.
/// </value>
return (this._timer !== null);
},
get_isPlaying : function() {
/// <value type="Boolean">
/// <code>true</code> if animation is playing, <code>false</code> if not.
/// </value>
return (this._timer !== null) && this._timer.get_enabled();
},
get_percentComplete : function() {
/// <value type="Number">
/// Percentage of the animation already played.
/// </value>
return this._percentComplete;
},
_getBoolean : function(value) {
/// <summary>
/// Helper to convert strings to booleans for property setters
/// </summary>
/// <param name="value" type="Object">
/// Value to convert if it's a string
/// </param>
/// <returns type="Object">
/// Value that has been converted if it was a string
/// </returns>
if (String.isInstanceOfType(value)) {
return Boolean.parse(value);
}
return value;
},
_getInteger : function(value) {
/// <summary>
/// Helper to convert strings to integers for property setters
/// </summary>
/// <param name="value" type="Object">Value to convert if it's a string</param>
/// <returns type="Object">Value that has been converted if it was a string</returns>
if (String.isInstanceOfType(value)) {
return parseInt(value);
}
return value;
},
_getFloat : function(value) {
/// <summary>
/// Helper to convert strings to floats for property setters
/// </summary>
/// <param name="value" type="Object">Value to convert if it's a string</param>
/// <returns type="Object">Value that has been converted if it was a string</returns>
if (String.isInstanceOfType(value)) {
return parseFloat(value);
}
return value;
},
_getEnum : function(value, type) {
/// <summary>
/// Helper to convert strings to enum values for property setters
/// </summary>
/// <param name="value" type="Object">Value to convert if it's a string</param>
/// <param name="type" type="Type">Type of the enum to convert to</param>
/// <returns type="Object">Value that has been converted if it was a string</returns>
if (String.isInstanceOfType(value) && type && type.parse) {
return type.parse(value);
}
return value;
}
}
$AA.Animation.registerClass('AjaxControlToolkit.Animation.Animation', Sys.Component);
$AA.registerAnimation('animation', $AA.Animation);
$AA.ParentAnimation = function(target, duration, fps, animations) {
/// <summary>
/// The <code>ParentAnimation</code> serves as a base class for all animations that contain children (such as
/// <see cref="AjaxControlToolkit.Animation.ParallelAnimation" />, <see cref="AjaxControlToolkit.SequenceAnimation" />,
/// etc.). It does not actually play the animations, so any classes that inherit from it must do so. Any animation
/// that requires nested child animations must inherit from this class, although it will likely want to inherit off of
/// <see cref="AjaxControlToolkit.Animation.ParallelAnimation" /> or <see cref="AjaxControlToolkit.SequenceAnimation" />
/// which will actually play their child animations.
/// </summary>
/// <param name="target" type="Sys.UI.DomElement" mayBeNull="true" optional="true" domElement="true">
/// Target of the animation
/// </param>
/// <param name="duration" type="Number" mayBeNull="true" optional="true">
/// Length of the animation in seconds. The default is 1.
/// </param>
/// <param name="fps" type="Number" mayBeNull="true" optional="true" integer="true">
/// Number of steps per second. The default is 25.
/// </param>
/// <param name="animations" mayBeNull="true" optional="true" parameterArray="true" elementType="AjaxControlToolkit.Animation.Animation">
/// Array of child animations to be played
/// </param>
/// <animation>Parent</animation>
$AA.ParentAnimation.initializeBase(this, [target, duration, fps]);
// Array of child animations (there are no assumptions placed on order because
// it will matter for some derived animations like SequenceAnimation, but not
// for others like ParallelAnimation) that is demand created in add
this._animations = [];
// Add any child animations passed into the constructor
if (animations && animations.length) {
for (var i = 0; i < animations.length; i++) {
this.add(animations[i]);
}
}
}
$AA.ParentAnimation.prototype = {
initialize : function() {
/// <summary>
/// Initialize the parent along with any child animations that have not yet been initialized themselves
/// </summary>
/// <returns />
$AA.ParentAnimation.callBaseMethod(this, 'initialize');
// Initialize all the uninitialized child animations
if (this._animations) {
for (var i = 0; i < this._animations.length; i++) {
var animation = this._animations[i];
if (animation && !animation.get_isInitialized) {
animation.initialize();
}
}
}
},
dispose : function() {
/// <summary>
/// Dispose of the child animations
/// </summary>
/// <returns />
this.clear();
this._animations = null;
$AA.ParentAnimation.callBaseMethod(this, 'dispose');
},
get_animations : function() {
/// <value elementType="AjaxControlToolkit.Animation.Animation">
/// Array of child animations to be played (there are no assumptions placed on order because it will matter for some
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -