Skip to content

Animation

cfry002 edited this page Feb 26, 2016 · 9 revisions

animateTo(props,timeInSeconds,interpolation,options,count)

##Description This method allows you to animate one or more numeric properties from their current values to a corresponding set of animation target values over a specified amount of time.

###Parameters props defines a set of properties on that target object along with target animation targets to tween the properties to.

timeInSeconds defines the amount of time it should take to tween the current values of the specified properties to their specified target values.

interpolation defines how the properties should be interpolated to their target values over time. The following constants are defined.

Constant Description
scene.LINEAR The value will be tweened linearly over the time specified.
scene.EXP1 TBD
scene.EXP2 TBD
scene.EXP3 TBD
scene.INQUAD TBD
scene.INCUBIC TBD
scene.INBACK TBD
scene.EASEINELASTIC TBD
scene.EASEOUTELASTIC TBD

options can be one of scene.LOOP or scene.OSCILLATE and defines whether the animation should start over from the beginning when the animation targets have been reached or whether it should "rewind" from the ending animation targets back to the property values of the object when then animation first commenced. In addition the constant, scene.FASTFORWARD or scene.REWIND can be bitwise or'ed with this parameter. If scene.FASTFORWARD is specified, then any previously running animateTo call that is cancelled by this new invocation will fast-forward to the animation targets specified in the previous animateTo call before starting this new animateTo animation. If scene.REWIND is specified, then any previously running animateTo call that is cancelled by this new invocation will 'rewind' to the property values prior to the start of the previous animateTo call before starting this new animateTo animation.

count defines how many times the animation should tween between the starting and ending point. A special constant, scene.FOREVER conveys that the animation should not end. In this case the promise associated with this animation will resolve immediately.

###Returns Returns a promise that will be fulfilled when the animation completes or will be rejected if the animation is cancelled. If a count of scene.FOREVER is specified, the promise will be fulfilled immediately. Otherwise, it will be fulfilled after count iterations of the animation have completed.

##Notes If multiple properties are animated within a single animateTo call and if the animation for any one of those properties is cancelled then the animation for all properties specified in the single animateTo call are cancelled. Other animations (different animateTo invocation) on the same object will not be affected.

A property animation can also be cancelled implicitly by setting one of the object's animating properties to a value. If the animation is cancelled in this way, none of the animating properties associated with the animateTo call will fast forward.

##Changes 02/26/2016

  • Added REWIND ##Changes 09/17/2015
  • Addition of the count parameter
  • Deprecating the scene.PX_STOP constant. Equivalent would be scene.LOOP with a count of 1
  • Addition of a scene.FOREVER constant (-1)
  • Deprecate the PX_SEESAW constant and replace with scene.OSCILLATE
  • Deprecate all PX_* constants and replace with the same constant names but removing the "PX_" prefix.
  • If animateTo is cancelled, the corresponding promise is rejected immediately.
  • If animateTo runs forever, the corresponding promise is resolved immediately.
  • Added a scene.FASTFORWARD flag that can be or'ed with the animationType value.
  • If multiple properties are animated within a single animateTo call and if the animation for any one of those properties is cancelled then the animation for all properties specified in the single animateTo call are cancelled. Other animations on the same object should not be affected.

Comments:

  • rewind bit for resetting animated properties to beginning when that animation is cancelled.
Clone this wiki locally