2008-12-23 JQuery 学习 Vol.5
时间:2008-12-24 来源:Givemefive
1. JQuery 动画
1.1 hide
hide(speed,callback)
Causes the elements in the wrapped set to become hidden. If called with no parameters, the operation takes place instantaneously by setting the display style property value of the elements to none. If a speed parameter is provided, the elements are hidden over a period of time by adjusting their size and opacity downward to zero, at which time their display style property value is set to none to remove them from the display. An optional callback can be specified that’s invoked when the animation is complete.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place, and the elements are immediately removed
from the display.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.2 show
show(speed,callback)
Causes any hidden elements in the wrapped set to be revealed. If called with no parameters, the operation takes place instantaneously by setting the display style property value of the elements to their previous setting (such as block or inline) if the element was hidden via a jQuery effect. If the element was not hidden via jQuery, the display style property value defaults to block. If a speed parameter is provided, the elements are revealed over a specified duration by
adjusting their size and opacity upward. An optional callback can be specified that’s invoked when the animation is complete.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place and the elements are immediately revealed in
the display.
callback (Function) An optional function invoked when the animation is complete. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.3 toggle
toggle(speed,callback)
Performs show() on any hidden wrapped elements and hide() on any non-hidden wrapped elements. See the syntax description of these commands for their respective semantics.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
callback (Function) An optional function invoked when the animation is complete. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.4 fadeOut
fadeOut(speed,callback)
Causes any matched elements that aren’t hidden to be removed from the display by gradually changing their opacity to 0% and then removing the element from the display. The duration of the change in opacity is determined by the speed parameter. Any elements that are already hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.5 fadeIn
fadeIn(speed,callback)
Causes any matched elements that are hidden to be shown by gradually changing their opacity to their natural value. This value is either the opacity originally applied to the element, or 100%. The duration of the change in opacity is determined by the speed parameter. Any elements that aren’t hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.6 fadeTo
fadeTo(speed,opacity,callback)
Adjusts the opacity of the wrapped elements from their current setting to the new setting specified by opacity.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
opacity (Number) The target opacity to which the elements will be adjusted specified as a value from 0.0 to 1.0.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.7 slideDown
slideDown(speed,callback)
Causes any matched elements that are hidden to be shown by gradually increasing their vertical size. Any elements that aren’t hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set
to the element that was animated.
Returns
The wrapped set.
1.8 slideUp
slideUp(speed,callback)
Causes any matched elements that aren’t hidden to be removed from the display by gradually decreasing their vertical size.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.9 slideToggle
slideToggle(speed,callback)
Performs slideDown() on any hidden wrapped elements and slideUp() on any non-hidden wrapped elements. See the syntax description of these commands for their respective semantics.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.10 stop
stop()
Halts all animations that may be currently in progress for the elements in the matched set
Parameters
none
Returns
The wrapped set
1.11 animate
animate(properties,duration,easing,callback)
animate(properties,options)
Applies an animation, as specified by the properties and easing parameters, to all members of the wrapped set. An optional callback function can be specified that’s invoked when the animation is complete. An alternate format specifies a set of options in addition to the properties.
Parameters
properties (Object) An object hash that specifies the end values that supported CSS styles should reach at the end of the animation. The animation takes place by adjusting the values of the style properties from the current value for an
element to the value specified in this object hash.
duration (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
easing (String) The optional name of a function to perform easing of the animation. Easing functions must be registered by name and are often provided
by plugins. Core jQuery supplies two easing functions registered as linear
and swing.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
options (Object) Specifies the animation parameter values using an object hash.
The supported properties are as follow:
■ duration—See previous description of duration parameter.
■ easing—See previous description of easing parameter.
■ complete—Function invoked when the animation completes.
■ queue—If false, the animation isn’t queued and begins running
immediately.
Returns
The wrapped set.
来自:Manning.jQuery.in.Action.Feb.2008.pdf
1.1 hide
hide(speed,callback)
Causes the elements in the wrapped set to become hidden. If called with no parameters, the operation takes place instantaneously by setting the display style property value of the elements to none. If a speed parameter is provided, the elements are hidden over a period of time by adjusting their size and opacity downward to zero, at which time their display style property value is set to none to remove them from the display. An optional callback can be specified that’s invoked when the animation is complete.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place, and the elements are immediately removed
from the display.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.2 show
show(speed,callback)
Causes any hidden elements in the wrapped set to be revealed. If called with no parameters, the operation takes place instantaneously by setting the display style property value of the elements to their previous setting (such as block or inline) if the element was hidden via a jQuery effect. If the element was not hidden via jQuery, the display style property value defaults to block. If a speed parameter is provided, the elements are revealed over a specified duration by
adjusting their size and opacity upward. An optional callback can be specified that’s invoked when the animation is complete.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place and the elements are immediately revealed in
the display.
callback (Function) An optional function invoked when the animation is complete. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.3 toggle
toggle(speed,callback)
Performs show() on any hidden wrapped elements and hide() on any non-hidden wrapped elements. See the syntax description of these commands for their respective semantics.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
callback (Function) An optional function invoked when the animation is complete. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.4 fadeOut
fadeOut(speed,callback)
Causes any matched elements that aren’t hidden to be removed from the display by gradually changing their opacity to 0% and then removing the element from the display. The duration of the change in opacity is determined by the speed parameter. Any elements that are already hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.5 fadeIn
fadeIn(speed,callback)
Causes any matched elements that are hidden to be shown by gradually changing their opacity to their natural value. This value is either the opacity originally applied to the element, or 100%. The duration of the change in opacity is determined by the speed parameter. Any elements that aren’t hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.6 fadeTo
fadeTo(speed,opacity,callback)
Adjusts the opacity of the wrapped elements from their current setting to the new setting specified by opacity.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
opacity (Number) The target opacity to which the elements will be adjusted specified as a value from 0.0 to 1.0.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.7 slideDown
slideDown(speed,callback)
Causes any matched elements that are hidden to be shown by gradually increasing their vertical size. Any elements that aren’t hidden aren’t affected.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set
to the element that was animated.
Returns
The wrapped set.
1.8 slideUp
slideUp(speed,callback)
Causes any matched elements that aren’t hidden to be removed from the display by gradually decreasing their vertical size.
Parameters
speed (Number|String) Specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, the default is normal.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.9 slideToggle
slideToggle(speed,callback)
Performs slideDown() on any hidden wrapped elements and slideUp() on any non-hidden wrapped elements. See the syntax description of these commands for their respective semantics.
Parameters
speed (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
Returns
The wrapped set.
1.10 stop
stop()
Halts all animations that may be currently in progress for the elements in the matched set
Parameters
none
Returns
The wrapped set
1.11 animate
animate(properties,duration,easing,callback)
animate(properties,options)
Applies an animation, as specified by the properties and easing parameters, to all members of the wrapped set. An optional callback function can be specified that’s invoked when the animation is complete. An alternate format specifies a set of options in addition to the properties.
Parameters
properties (Object) An object hash that specifies the end values that supported CSS styles should reach at the end of the animation. The animation takes place by adjusting the values of the style properties from the current value for an
element to the value specified in this object hash.
duration (Number|String) Optionally specifies the duration of the effect as a number of milliseconds or as one of the predefined strings: slow, normal, or fast. If omitted, no animation takes place.
easing (String) The optional name of a function to perform easing of the animation. Easing functions must be registered by name and are often provided
by plugins. Core jQuery supplies two easing functions registered as linear
and swing.
callback (Function) An optional function invoked when the animation completes. No parameters are passed to this function, but the function context (this) is set to the element that was animated.
options (Object) Specifies the animation parameter values using an object hash.
The supported properties are as follow:
■ duration—See previous description of duration parameter.
■ easing—See previous description of easing parameter.
■ complete—Function invoked when the animation completes.
■ queue—If false, the animation isn’t queued and begins running
immediately.
Returns
The wrapped set.
来自:Manning.jQuery.in.Action.Feb.2008.pdf
相关阅读 更多 +