Titanium.UI.iOS.Animator
> Titanium.UI.iOS.Animator

Provides support for the built-in iOS dynamic animations

Requires: iOS 7.0 and later

The following APIs are supported on iOS 7 and later.

The animator provides physics-related capabilities and animations using the iOS physics engine. Each animator is independent of other animators you create. An animator is comprised of behaviors and items. Behaviors define the rules of the animation, while items are the view objects to be animated. An item in the animator can be given multiple behaviors as long as those behaviors belong to the same animator.

To use these dynamic animations, first create the items to animate, then:

1. Create an animator using the Titanium.UI.iOS.createAnimator method.

2. Set the referenceView property to establish the coordinate system for the animations.

3. Create and add items to one or more of the following behaviors:

4. Add these behaviors to the animator with the addBehavior method.

5. Start the animator with startAnimator method.

Once all items are at rest, the animator automatically pauses, and resumes if a behavior parameter changes, or a behavior or item is added or removed.

See the behaviors listed above for examples of animating items.

Reference View

The Titanium view object set to the Animator's referenceView property establishes the coordinate system for the animation behaviors and items. Each item that needs to be animated must be a child of the reference view.

By default, when you create a collision behavior, the behavior uses the edge's of the reference view as its boundary, so any item within this view cannot be pushed out of it.

Use the following lists as references when specifying your animation behaviors.

Points

The following list notes the location of notable points in the coordinate system, where WIDTH and HEIGHT are the width and height of the reference view, respectively.

  • Top-left corner: (0,0)
  • Top-right corner: (WIDTH, 0)
  • Center: (WIDTH/2, HEIGHT/2)
  • Bottom-left corner: (0, HEIGHT)
  • Bottom-right corner: (WIDTH, HEIGHT)

Note that on iOS a point is equivalent to a display pixel.

Vectors

Gravity and push forces may be specified as vectors with the gravityDirection and pushDirection properties, respectively. The following list notes the direction and its corresponding vector:

  • Left: (-x,0)
  • Right: (+x,0)
  • Up: (0,-y)
  • Down: (0,+y)

Angles

Gravity and push forces may be specified with the angle and magnitude properties. Specify all angle values as radians (360 degrees = 2 * pi radians). The following list notes the direction and its corresponding angle:

  • Right: 0 or 2 * pi
  • Down: pi / 2
  • Left: pi
  • Up: pi / 2 * 3
  • 3.2
  • 3.2
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Titanium.UI.iOS.Animator
behaviors : Titanium.Proxy[]

Behaviors associated with this animator.

Behaviors associated with this animator.

Indicates if the proxy will bubble an event to its parent. ...

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0.0
  • 3.0.0
  • 3.0.0

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Titanium.UI.iOS.Animator
referenceView : Titanium.UI.View

Titanium View object to initialize as the reference view for the animator.

Titanium View object to initialize as the reference view for the animator.

When adding behavior and dynamic items to the animator, the animator bases its coordindate system on the reference view.

Titanium.UI.iOS.Animator
running : Booleanreadonly

Returns true if the animator is running else false.

Returns true if the animator is running else false.

Defined By

Methods

Titanium.UI.iOS.Animator
( behavior )
Adds a dynamic behavior to the animator. ...

Adds a dynamic behavior to the animator.

Specify an instance of one of the following Titanium behavior proxies:

Parameters

Returns

  • void
Adds the specified callback as an event listener for the named event. ...

Adds the specified callback as an event listener for the named event.

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to invoke when the event is fired.

Returns

  • void
Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Fires a synthesized event to any registered listeners. ...

Fires a synthesized event to any registered listeners.

Parameters

  • name : String

    Name of the event.

  • event : Dictionary

    A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

  • void
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Titanium.UI.iOS.Animator
( ) : Titanium.Proxy[]
Gets the value of the behaviors property. ...

Gets the value of the behaviors property.

Returns

Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • Boolean
Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Titanium.UI.iOS.Animator
( ) : Titanium.UI.View
Gets the value of the referenceView property. ...

Gets the value of the referenceView property.

Returns

Titanium.UI.iOS.Animator
( ) : Boolean
Gets the value of the running property. ...

Gets the value of the running property.

Returns

  • Boolean
Titanium.UI.iOS.Animator
( )
Removes all behaviors from this animator. ...

Removes all behaviors from this animator.

Returns

  • void
Titanium.UI.iOS.Animator
( behavior )
Removes the specified behavior from the animator. ...

Removes the specified behavior from the animator.

Specifiy an instance of one of the following Titanium behavior proxies:

Parameters

Returns

  • void
Removes the specified callback as an event listener for the named event. ...

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to remove. Must be the same function passed to addEventListener.

Returns

  • void
Titanium.UI.iOS.Animator
( behaviors )
Sets the value of the behaviors property. ...

Sets the value of the behaviors property.

Parameters

Returns

  • void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Titanium.UI.iOS.Animator
( referenceView )
Sets the value of the referenceView property. ...

Sets the value of the referenceView property.

Parameters

Returns

  • void
Titanium.UI.iOS.Animator
( )
Starts the animation behaviors. ...

Starts the animation behaviors.

Returns

  • void
Titanium.UI.iOS.Animator
( )
Stops the animation behaviors. ...

Stops the animation behaviors.

Returns

  • void
Titanium.UI.iOS.Animator
( item )
Updates the animator's state information with the current state of the specified item. ...

Updates the animator's state information with the current state of the specified item.

When an item is first added to the animator, the animator reads the initial state of the item, then takes responsibility for updating it. If you actively make changes to the item's properties, such as changing its position or dimensions, use this method to update the item's new state.

Parameters

Returns

  • void
Defined By

Events

Titanium.UI.iOS.Animator
Fired when the animator paused its animations. ...

Fired when the animator paused its animations.

Properties

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Titanium.UI.iOS.Animator
Fired when the animator resumes its animations. ...

Fired when the animator resumes its animations.

Properties

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •