Packagecom.greensock.easing
Classpublic class SlowMo
InheritanceSlowMo Inheritance Ease Inheritance Object

SlowMo is a configurable ease that produces a slow-motion effect that decelerates initially, then moves linearly for a certain portion of the ease (which you can choose) and then accelerates again at the end; it's great for effects like zooming text onto the screen, smoothly moving it long enough for people to read it, and then zooming it off the screen. Without SlowMo, animators would often try to get the same effect by sequencing 3 tweens, one with an easeOut, then another with a Linear.easeNone, and finally an easeIn but the problem was that the eases didn't smoothly transition into one another, so you'd see sudden shifts in velocity at the joints. SlowMo solves this problem and gives you complete control over how strong the eases are on each end and what portion of the movement in the middle is linear.

The first parameter, linearRatio, determines the proportion of the ease during which the rate of change will be linear (steady pace). This should be a number between 0 and 1. For example, 0.5 would be half, so the first 25% of the ease would be easing out (decelerating), then 50% would be linear, then the final 25% would be easing in (accelerating). If you choose 0.8, that would mean 80% of the ease would be linear, leaving 10% on each end to ease. The default is 0.7.

The second parameter, power, determines the strength of the ease at each end. If you define a value greater than 1, it will actually reverse the linear portion in the middle which can create interesting effects. The default is 0.7.

The third parameter, yoyoMode, provides an easy way to create companion tweens that sync with normal SlowMo tweens. For example, let's say you have a SlowMo tween that is zooming some text onto the screen and moving it linearly for a while and then zooming off, but you want to tween that alpha of the text at the beginning and end of the positional tween. Normally, you'd need to create 2 separate alpha tweens, 1 for the fade-in at the beginning and 1 for the fade-out at the end and you'd need to calculate their durations manually to ensure that they finish fading in by the time the linear motion begins and then they start fading out at the end right when the linear motion completes. But to make this whole process much easier, all you'd need to do is create a separate tween for the alpha and use the same duration but a SlowMo ease that has its yoyoMode parameter set to true.

View the examples



Public Properties
 PropertyDefined By
  ease : SlowMo
[static] The default ease instance which can be reused many times in various tweens in order to conserve memory and improve performance slightly compared to creating a new instance each time.
SlowMo
Public Methods
 MethodDefined By
  
SlowMo(linearRatio:Number = 0.7, power:Number = 0.7, yoyoMode:Boolean = false)
Constructor
SlowMo
  
config(linearRatio:Number = 0.7, power:Number = 0.7, yoyoMode:Boolean = false):SlowMo
Permits customization of the ease with various parameters.
SlowMo
  
getRatio(p:Number):Number
[override] Translates the tween's progress ratio into the corresponding ease ratio.
SlowMo
Property Detail
easeproperty
public static var ease:SlowMo

The default ease instance which can be reused many times in various tweens in order to conserve memory and improve performance slightly compared to creating a new instance each time.

Constructor Detail
SlowMo()Constructor
public function SlowMo(linearRatio:Number = 0.7, power:Number = 0.7, yoyoMode:Boolean = false)

Constructor

Parameters
linearRatio:Number (default = 0.7) — the proportion of the ease during which the rate of change will be linear (steady pace). This should be a number between 0 and 1. For example, 0.5 would be half, so the first 25% of the ease would be easing out (decelerating), then 50% would be linear, then the final 25% would be easing in (accelerating). If you choose 0.8, that would mean 80% of the ease would be linear, leaving 10% on each end to ease. The default is 0.7.
 
power:Number (default = 0.7) — The strength of the ease at each end. If you define a value above 1, it will actually reverse the linear portion in the middle which can create interesting effects. The default is 0.7.
 
yoyoMode:Boolean (default = false) — If true, the ease will reach its destination value mid-tween and maintain it during the entire linear mode and then go back to the original value at the end (like a yoyo of sorts). This can be very useful if, for example, you want the alpha (or some other property) of some text to fade at the front end of a SlowMo positional ease and then back down again at the end of that positional SlowMo tween. Otherwise you would need to create separate tweens for the beginning and ending fades that match up with that positional tween. Example: TweenLite.to(myText, 5, {x:600, ease:SlowMo.ease.config(0.7, 0.7, false)}); TweenLite.from(myText, 5, {alpha:0, ease:SlowMo.ease.config(0.7, 0.7, true)});
Method Detail
config()method
public function config(linearRatio:Number = 0.7, power:Number = 0.7, yoyoMode:Boolean = false):SlowMo

Permits customization of the ease with various parameters.

Parameters

linearRatio:Number (default = 0.7) — the proportion of the ease during which the rate of change will be linear (steady pace). This should be a number between 0 and 1. For example, 0.5 would be half, so the first 25% of the ease would be easing out (decelerating), then 50% would be linear, then the final 25% would be easing in (accelerating). If you choose 0.8, that would mean 80% of the ease would be linear, leaving 10% on each end to ease. The default is 0.7.
 
power:Number (default = 0.7) — The strength of the ease at each end. If you define a value above 1, it will actually reverse the linear portion in the middle which can create interesting effects. The default is 0.7.
 
yoyoMode:Boolean (default = false) — If true, the ease will reach its destination value mid-tween and maintain it during the entire linear mode and then go back to the original value at the end (like a yoyo of sorts). This can be very useful if, for example, you want the alpha (or some other property) of some text to fade at the front end of a SlowMo positional ease and then back down again at the end of that positional SlowMo tween. Otherwise you would need to create separate tweens for the beginning and ending fades that match up with that positional tween. Example: TweenLite.to(myText, 5, {x:600, ease:SlowMo.ease.config(0.7, 0.7, false)}); TweenLite.from(myText, 5, {alpha:0, ease:SlowMo.ease.config(0.7, 0.7, true)});

Returns
SlowMo — new SlowMo instance that is configured according to the parameters provided
getRatio()method 
override public function getRatio(p:Number):Number

Translates the tween's progress ratio into the corresponding ease ratio. This is the heart of the Ease, where it does all its work.

Parameters

p:Number — progress ratio (a value between 0 and 1 indicating the progress of the tween/ease)

Returns
Number — translated number
Examples
Example AS3 example:
import com.greensock.*;
import com.greensock.easing.*;

//use the default SlowMo ease (linearRatio of 0.7 and power of 0.7)
TweenLite.to(myText, 5, {x:600, ease:SlowMo.ease});

//use a new SlowMo ease with 50% of the tween being linear (2.5 seconds) and a power of 0.8
TweenLite.to(myText, 5, {x:600, ease:new SlowMo(0.5, 0.8)});
 
//this gives the exact same effect as the line above, but uses a different syntax
TweenLite.to(myText, 5, {x:600, ease:SlowMo.ease.config(0.5, 0.8)});
 
//now let's create an alpha tween that syncs with the above positional tween, fading it in at the beginning and out at the end
myText.alpha = 0;
TweenLite.to(myText, 5, {alpha:1, ease:SlowMo.ease.config(0.5, 0.8, true)});

Copyright 2012, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.