Class YAHOO.util.Anim

Object
   |
   +--YAHOO.util.Anim
Direct Known Subclasses:
YAHOO.util.ColorAnim

class YAHOO.util.Anim
Requires:
YAHOO.util.AnimMgr
YAHOO.util.Easing
YAHOO.util.Dom
YAHOO.util.Event
YAHOO.util.CustomEvent

Base animation class that provides the interface for building animated effects.

Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);

Field Summary [top]

Object attributes
The collection of attributes to be animated. 
Int currentFrame
The location of the current animation on the timeline. 
Number duration
The length of the animation. 
Function method
The method that will provide values to the attribute(s) during the animation. 
CustomEvent onComplete
Custom event that fires when animation ends Listen via subscribe method (e.g. 
CustomEvent onStart
Custom event that fires when animation begins Listen via subscribe method (e.g. 
CustomEvent onTween
Custom event that fires between each frame Listen via subscribe method (e.g. 
Int totalFrames
The total number of frames to be executed. 
Boolean useSeconds
Whether or not the duration should be treated as seconds. 

Constructor Summary [top]

YAHOO.util.Anim
Base class for animated DOM objects. 

Method Summary [top]

Object animate ()
Starts the animation by registering it with the animation manager. 
Number doMethod (<String> attr, <Number> start, <Number> end)
Returns the value computed by the animation's "method". 
Number getAttribute (<String> attr)
Returns current value of the attribute. 
String getDefaultUnit (<attr> attr)
Returns the unit to use when none is supplied. 
HTMLElement getEl ()
Returns a reference to the animated element. 
Date getStartTime ()
Returns the animation start time. 
void init (el, <Object> attributes, <Number> duration, <Function> method)
 
Boolean isAnimated ()
Checks whether the element is currently animated. 
void setAttribute (<String> attr, <Number> val, <String> unit)
Applies a value to an attribute 
void stop ()
Stops the animation. 
String toString ()
toString method 

Field Detail [top]

attributes

Object   attributes
The collection of attributes to be animated. Each attribute must have at least a "to" or "by" defined in order to animate. If "to" is supplied, the animation will end with the attribute at that value. If "by" is supplied, the animation will end at that value plus its starting value. If both are supplied, "to" is used, and "by" is ignored.

currentFrame

Int   currentFrame
The location of the current animation on the timeline. In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.

duration

Number   duration
The length of the animation. Defaults to "1" (second).

method

Function   method
The method that will provide values to the attribute(s) during the animation. Defaults to "YAHOO.util.Easing.easeNone".

onComplete

CustomEvent   onComplete
Custom event that fires when animation ends Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)

onStart

CustomEvent   onStart
Custom event that fires when animation begins Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)

onTween

CustomEvent   onTween
Custom event that fires between each frame Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)

totalFrames

Int   totalFrames
The total number of frames to be executed. In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.

useSeconds

Boolean   useSeconds
Whether or not the duration should be treated as seconds. Defaults to true.

Constructor Detail [top]

YAHOO.util.Anim

YAHOO.util.Anim ()
Base class for animated DOM objects.
Parameters:
el - Reference to the element that will be animated. Can be an ID or HTMLElement.
attributes - The attribute(s) to be animated. Each attribute is an object with at minimum a "to" or "by" member defined. Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). All attribute names use camelCase.
duration - (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
method - (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)

Method Detail [top]

animate

Object animate ()
Starts the animation by registering it with the animation manager.

doMethod

Number doMethod (<String> attr, <Number> start, <Number> end)
Returns the value computed by the animation's "method".
Parameters:
attr - The name of the attribute.
start - The value this attribute should start from for this animation.
end - The value this attribute should end at for this animation.
Returns:
The Value to be applied to the attribute.

getAttribute

Number getAttribute (<String> attr)
Returns current value of the attribute.
Parameters:
attr - The name of the attribute.
Returns:
val The current value of the attribute.

getDefaultUnit

String getDefaultUnit (<attr> attr)
Returns the unit to use when none is supplied. Applies the "defaultUnit" test to decide whether to use pixels or not
Parameters:
attr - The name of the attribute.
Returns:
The default unit to be used.

getEl

HTMLElement getEl ()
Returns a reference to the animated element.

getStartTime

Date getStartTime ()
Returns the animation start time.
Returns:
current value of startTime.

init

void init (el, <Object> attributes, <Number> duration, <Function> method)
Parameters:
el - Reference to the element that will be animated. Can be an ID or HTMLElement.
attributes - The attribute(s) to be animated. Each attribute is an object with at minimum a "to" or "by" member defined. Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). All attribute names use camelCase.
duration - (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
method - (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)

isAnimated

Boolean isAnimated ()
Checks whether the element is currently animated.
Returns:
current value of isAnimated.

setAttribute

void setAttribute (<String> attr, <Number> val, <String> unit)
Applies a value to an attribute
Parameters:
attr - The name of the attribute.
val - The value to be applied to the attribute.
unit - The unit ('px', '%', etc.) of the value.

stop

void stop ()
Stops the animation. Normally called by AnimMgr when animation completes.

toString

String toString ()
toString method
Returns:
string represenation of anim obj