Print Friendly

# Class YAHOO.ext.Animator

Package: | YAHOO.ext
Class: | Animator
Extends: | Object
Defined In: | Animator.js

Provides support for syncing animations for multiple YAHOO.ext.Actors.
This example can be seen in action here by clicking on "Click here and I will point it out" at the end of the first paragraph.

    var animator = new YAHOO.ext.Animator();
    var cursor = new YAHOO.ext.Actor('cursor-img', animator);
    var click = new YAHOO.ext.Actor('click-img', animator);
    var resize = new YAHOO.ext.Actor('resize-img', animator);

    // start capturing
    animator.startCapture();

    // these animations will be run in sequence
    cursor.show();
    cursor.moveTo(500,400);
    cursor.moveTo(20, getEl('navbar').getY()+10, true, .75);
    click.show();
    click.alignTo(cursor, 'tl', [-4, -4]);

    // Add an async function call, pass callback to argument 1
    animator.addAsyncCall(Blog.navbar.undockDelegate, 1);

    // pause .5 seconds
    animator.pause(.5);

    // again, these animations will be run in sequence
    click.hide(true, .7);
    cursor.alignTo('splitter', 'tr', [0, +100], true, 1);
    resize.alignTo('splitter', 'tr', [-12, +100]);

    // start sync block: these animations will run at the same time
    animator.beginSync();
    cursor.hide();
    resize.show();
    animator.endSync();

    // play the captured animation sequences, call myCallback when done
    animator.play(myCallback);

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| Animator(`String/HTMLElement el`, [`YAHOO.ext.Animator animator`], [`Boolean selfCapture`]) | Animator
| addActor(`YAHOO.ext.Actor actor`) : void | Animator
Add an actor. The actor is also set to capturing = true.
| addAsyncCall(`Function fcn`, `Number callbackIndex`, [`Array args`], [`Object scope`]) : void | Animator
Add an async function call to the playlist.
| addCall(`Function fcn`, [`Array args`], [`Object scope`]) : void | Animator
Add a function call to the playlist.
| beginSync() : void | Animator
Start a multi-actor sync block. By default all animations are run in sequence. While in the sync block each actor's o...
| clear() : void | Animator
Clear the playlist
| endSync() : void | Animator
End the multi-actor sync block
| isCapturing(`YAHOO.ext.Actor actor`) : void | Animator
Checks whether this animator is listening to a specific actor.
| isPlaying() : void | Animator
Check if this animator is currently playing
| pause(`Number seconds`) : void | Animator
Add a pause to the playlist (in seconds)
| play([`Function oncomplete`]) : void | Animator
Starts playback of the playlist, also stops any capturing. To start capturing again call startCapture.
| select<static>(`String/Array selector`) : void | Animator
<static> Static function to build a AnimatorComposite from a css selector (requires YAHOO.ext.Element.selectorF...
| startCapture([`Boolean clearPlaylist`]) : void | Animator
Start capturing actions on the added actors.
| stop() : void | Animator
Stop at the next available stopping point
| stopCapture() : void | Animator
Stop capturing on all added actors.

## Public Events

This class has no public events.

## Constructor Details

### Animator

`public function Animator(`String/HTMLElement el`, [`YAHOO.ext.Animator animator`], [`Boolean selfCapture`])`
Parameters:

- `el` : String/HTMLElement
  The dom element or element id
- `animator` : YAHOO.ext.Animator
  (optional) The Animator that will capture this Actor's actions
- `selfCapture` : Boolean
  (optional) Whether this actor should capture it's own actions to support self playback without an animator (defaults to false)

## Method Details

### addActor

`public function addActor(`YAHOO.ext.Actor actor`)`
Add an actor. The actor is also set to capturing = true.
Parameters:

- `actor` : YAHOO.ext.Actor

Returns:

- `void`

This method is defined by Animator.

### addAsyncCall

`public function addAsyncCall(`Function fcn`, `Number callbackIndex`, [`Array args`], [`Object scope`])`
Add an async function call to the playlist.
Parameters:

- `fcn` : Function
  The function to call
- `callbackIndex` : Number
  The index of the callback parameter on the passed function. A CALLBACK IS REQUIRED.
- `args` : Array
  The arguments to call the function with
- `scope` : Object
  (optional) The scope of the function

Returns:

- `void`

This method is defined by Animator.

### addCall

`public function addCall(`Function fcn`, [`Array args`], [`Object scope`])`
Add a function call to the playlist.
Parameters:

- `fcn` : Function
  The function to call
- `args` : Array
  The arguments to call the function with
- `scope` : Object
  (optional) The scope of the function

Returns:

- `void`

This method is defined by Animator.

### beginSync

`public function beginSync()`
Start a multi-actor sync block. By default all animations are run in sequence. While in the sync block each actor's own animations will still be sequenced, but all actors will animate at the same time.
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

### clear

`public function clear()`
Clear the playlist
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

### endSync

`public function endSync()`
End the multi-actor sync block
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

### isCapturing

`public function isCapturing(`YAHOO.ext.Actor actor`)`
Checks whether this animator is listening to a specific actor.
Parameters:

- `actor` : YAHOO.ext.Actor

Returns:

- `void`

This method is defined by Animator.

### isPlaying

`public function isPlaying()`
Check if this animator is currently playing
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

### pause

`public function pause(`Number seconds`)`
Add a pause to the playlist (in seconds)
Parameters:

- `seconds` : Number
  The number of seconds to pause.

Returns:

- `void`

This method is defined by Animator.

### play

`public function play([`Function oncomplete`])`
Starts playback of the playlist, also stops any capturing. To start capturing again call startCapture.
Parameters:

- `oncomplete` : Function
  (optional) Callback to execute when playback has completed

Returns:

- `void`

This method is defined by Animator.

### select<static>

`public function select<static>(`String/Array selector`)`
<static> Static function to build a AnimatorComposite from a css selector (requires YAHOO.ext.Element.selectorFunction be defined)
Parameters:

- `selector` : String/Array
  The css selector or an array of nodes to animate

Returns:

- `void`

This method is defined by Animator.

### startCapture

`public function startCapture([`Boolean clearPlaylist`])`
Start capturing actions on the added actors.
Parameters:

- `clearPlaylist` : Boolean
  Whether to also create a new playlist

Returns:

- `void`

This method is defined by Animator.

### stop

`public function stop()`
Stop at the next available stopping point
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

### stopCapture

`public function stopCapture()`
Stop capturing on all added actors.
Parameters:

- None.

Returns:

- `void`

This method is defined by Animator.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.