GreenSock JavaScript API Docs | All Packages | All Classes | Index | Frames No Frames |
Ease

Package | com.greensock.easing
Class | public class Ease
Inheritance | Ease Object
Subclasses | Linear, SlowMo, SteppedEase

Base class for all GreenSock easing equations. In its simplest form, an Ease is responsible for translating linear time (typically represented as a number between 0 and 1 where 0 is the beginning, 0.5 is halfway complete, and 1 is the end) into a value that has a different rate of change but still starts at 0 and ends at 1. In the GreenSock platform, eases are used to give tweens/animations the look and feel that the animator desires. For example, a ball rolling to a stop would decelerate over time (easeOut) rather than using a linear velocity. An Elastic ease could be used to make an object appear as though it is loosely attached somewhere and is snapping into place with loose (or tight) tension.

All Ease instances have a `getRatio()` method that is responsible for the translation of the progress ratio which the tween typically feeds in. End users almost never need to directly feed any values to or get any values from an Ease instance - the tweens will do that internally.

The base Ease class handles most of the common power-based easeIn/easeOut/eaesInOut calculations (like Linear, Quad, Cubic, Quart, Quint, and Strong) internally. You can define a separate function that uses what was considered the 4 standard easing parameters by Adobe and many others (time, start, change, duration) and Ease will serve as a proxy in order to maximize backwards compatibility and usability. For example, if you have a custom method that you created like this:

    function myEase(t:Number, s:Number, c:Number, d:Number):Number {
        return s+(t=t/d);
    }

You could still use that by wrapping Ease around it like this:

    import com.greensock.*;
    import com.greensock.easing.*;

    TweenLite.to(mc, 5, {x:600, ease:new Ease(myEase)});

In the above example, the anytime the Ease's `getRatio()` method is called, it would feed the first parameter as a ratio between 0 and 1 and the rest of the 3 parameters would always be 0, 1, 1. This is all done transparently by TweenLite/TweenMax, so you really shouldn't need to worry about this.

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.

Public Methods

| Method | Defined By
--- | --- | ---
|  | Ease(func:Function = null, extraParams:Array = null, type:Number = 0, power:Number = 0) Constructor | Ease
|  | getRatio(p:Number):Number Translates the tween's progress ratio into the corresponding ease ratio. | Ease

Constructor Detail

Ease | () | Constructor

`public function Ease(func:Function = null, extraParams:Array = null, type:Number = 0, power:Number = 0)`

Constructor

Parameters

| `func:Function` (default = `null`)`` — Function (if any) that should be proxied. This is completely optional and is in fact rarely used except when you have your own custom ease function that follows the standard ease parameter pattern like time, start, change, duration.
| `extraParams:Array` (default = `null`)`` — If any extra parameters beyond the standard 4 (time, start, change, duration) need to be fed to the `func` function, define them as an array here. For example, the old Elastic.easeOut accepts 2 extra parameters in its standard equation (although the newer GreenSock version uses the more modern `config()` method for configuring the ease and doesn't require any extraPrams here)
| `type:Number` (default = `0`)`` — Integer indicating the type of ease where 1 is easeOut, 2 is easeIn, 3 is easeInOut, and 0 is none of these.
| `power:Number` (default = `0`)`` — Power of the ease where Linear is 0, Quad is 1, Cubic is 2, Quart is 3, Quint (and Strong) is 4, etc.

Method Detail

getRatio | () | method

`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

Thu Dec 20 2012, 04:30 PM -06:00