parallaxis/duo/js/greensock-v12-js/docs/com/greensock/easing/Ease.html

74 lines
11 KiB
HTML
Executable File

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- saved from url=(0014)about:internet --><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" href="../../../style.css" type="text/css" media="screen"><link rel="stylesheet" href="../../../print.css" type="text/css" media="print"><link rel="stylesheet" href="../../../override.css" type="text/css"><meta name="keywords" content="Ease,com.greensock.easing.Ease,config,config,find,getRatio,getRatio,getRatio"><title>com.greensock.easing.Ease</title></head><body><script language="javascript" type="text/javascript" src="../../../asdoc.js"></script><script language="javascript" type="text/javascript" src="../../../help.js"></script><script language="javascript" type="text/javascript" src="../../../cookies.js"></script><script language="javascript" type="text/javascript"><!--
asdocTitle = 'Ease - GreenSock JavaScript Documentation';
var baseRef = '../../../';
window.onload = configPage;
--></script>
<script type="text/javascript">
scrollToNameAnchor();
</script><table class="titleTable" cellpadding="0" cellspacing="0" id="titleTable" style="display:none"><tr><td class="titleTableTitle" align="left">GreenSock JavaScript API Docs</td><td class="titleTableTopNav" align="right"><a href="../../../package-summary.html" onclick="loadClassListFrame('../../../all-classes.html')">All Packages</a>&nbsp;|&nbsp;<a href="../../../class-summary.html" onclick="loadClassListFrame('../../../all-classes.html')">All Classes</a>&nbsp;|&nbsp;<a href="../../../all-index-A.html" onclick="loadClassListFrame('../../../index-list.html')">Index</a>&nbsp;|&nbsp;<a id="framesLink1" href="../../../index.html?com/greensock/easing/Ease.html&amp;com/greensock/easing/class-list.html">Frames</a><a id="noFramesLink1" style="display:none" href="" onclick="parent.location=document.location"> No Frames </a></td><td class="titleTableLogo" align="right" rowspan="3"><img src="../../../images/logo.jpg" class="logoImage" alt=" Adobe Logo " title=" Adobe Logo "></td></tr><tr class="titleTableRow2"><td class="titleTableSubTitle" id="subTitle" align="left">Ease</td><td class="titleTableSubNav" id="subNav" align="right"><a href="#methodSummary">Methods</a></td></tr><tr class="titleTableRow3"><td colspan="3">&nbsp;</td></tr></table><script language="javascript" type="text/javascript" xml:space="preserve">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Ease"); titleBar_setSubNav(false,false,false,false,false,false,false,false,true,false,false ,false,false,false,false,false);}
-->
</script><div xmlns:fn="http://www.w3.org/2005/xpath-functions" class="MainContent"><table class="classHeaderTable" cellpadding="0" cellspacing="0"><tr><td class="classHeaderTableLabel">Package</td><td><a href="package-detail.html" onclick="javascript:loadClassListFrame('class-list.html')">com.greensock.easing</a></td></tr><tr><td class="classHeaderTableLabel">Class</td><td class="classSignature">public class Ease</td></tr><tr><td class="classHeaderTableLabel">Inheritance</td><td class="inheritanceList">Ease <img src="../../../images/inherit-arrow.gif" title="Inheritance" alt="Inheritance" class="inheritArrow"> Object</td></tr><tr><td class="classHeaderTableLabel">Subclasses</td><td> <a href="../../../com/greensock/easing/Linear.html">Linear</a>, <a href="../../../com/greensock/easing/SlowMo.html">SlowMo</a>, <a href="../../../com/greensock/easing/SteppedEase.html">SteppedEase</a></td></tr></table><p></p><p></p><p></p>
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.
<p>All Ease instances have a <code>getRatio()</code> 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.</p>
<p>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:</p>
<div class="listing" version="3.0"><pre>
function myEase(t:Number, s:Number, c:Number, d:Number):Number {
return s+(t=t/d);
}
</pre></div>
You could still use that by wrapping Ease around it like this:
<div class="listing" version="3.0"><pre>
import com.greensock.*;
import com.greensock.easing.*;
TweenLite.to(mc, 5, {x:600, ease:new Ease(myEase)});
</pre></div>
<p>In the above example, the anytime the Ease's <code>getRatio()</code> 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.</p>
<p>
<b>Copyright 2012, GreenSock. All rights reserved.</b> This work is subject to the terms in <a href="http://www.greensock.com/terms_of_use.html" target="">http://www.greensock.com/terms_of_use.html</a> or for <a href="http://www.greensock.com/club/" target="">Club GreenSock</a> members, the software agreement that was issued with the membership.</p>
<p></p><br/><hr></div><a name="methodSummary"></a><div class="summarySection"><div class="summaryTableTitle">Public Methods </div><table cellspacing="0" cellpadding="3" class="summaryTable " id="summaryTableMethod"><tr><th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined By</th></tr><tr class=""><td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><div class="summarySignature"><a href="#Ease()" class="signatureLink">Ease</a>(func:Function = null, extraParams:Array = null, type:Number = 0, power:Number = 0)</div><div class="summaryTableDescription">
Constructor
</div></td><td class="summaryTableOwnerCol">Ease</td></tr><tr class=""><td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><div class="summarySignature"><a href="#getRatio()" class="signatureLink">getRatio</a>(p:Number):Number</div><div class="summaryTableDescription">
Translates the tween's progress ratio into the corresponding ease ratio.</div></td><td class="summaryTableOwnerCol">Ease</td></tr></table></div><script language="javascript" type="text/javascript"><!--
showHideInherited();
--></script><div class="MainContent"><a name="constructorDetail"></a><div class="detailSectionHeader">Constructor Detail</div><a name="Ease()"></a><a name="Ease(Function,Array,Number,Number)"></a><table class="detailHeader" cellpadding="0" cellspacing="0"><tr><td class="detailHeaderName">Ease</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">Constructor</td></tr></table><div class="detailBody"><code>public function Ease(func:Function = null, extraParams:Array = null, type:Number = 0, power:Number = 0)</code><p></p><p>
Constructor
</p><span class="label"> Parameters </span><table cellpadding="0" cellspacing="0" border="0"><tr><td width="20px"></td><td><code><span class="label">func</span>:Function</code> (default = <code>null</code>)<code></code> &mdash; 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.
</td></tr><tr><td class="paramSpacer">&nbsp;</td></tr><tr><td width="20px"></td><td><code><span class="label">extraParams</span>:Array</code> (default = <code>null</code>)<code></code> &mdash; If any extra parameters beyond the standard 4 (time, start, change, duration) need to be fed to the <code>func</code> 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 <code>config()</code> method for configuring the ease and doesn't require any extraPrams here)
</td></tr><tr><td class="paramSpacer">&nbsp;</td></tr><tr><td width="20px"></td><td><code><span class="label">type</span>:Number</code> (default = <code>0</code>)<code></code> &mdash; Integer indicating the type of ease where 1 is easeOut, 2 is easeIn, 3 is easeInOut, and 0 is none of these.
</td></tr><tr><td class="paramSpacer">&nbsp;</td></tr><tr><td width="20px"></td><td><code><span class="label">power</span>:Number</code> (default = <code>0</code>)<code></code> &mdash; Power of the ease where Linear is 0, Quad is 1, Cubic is 2, Quart is 3, Quint (and Strong) is 4, etc.
</td></tr></table></div><a name="methodDetail"></a><div class="detailSectionHeader">Method Detail</div><a name="getRatio()"></a><a name="getRatio(Number)"></a><table class="detailHeader" cellpadding="0" cellspacing="0"><tr><td class="detailHeaderName">getRatio</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td></tr></table><div class="detailBody"><code> public function getRatio(p:Number):Number</code><p></p><p></p><p>
Translates the tween's progress ratio into the corresponding ease ratio. This is the heart of the Ease, where it does all its work.
</p><p><span class="label"> Parameters </span><table cellpadding="0" cellspacing="0" border="0"><tr><td width="20px"></td><td><code><span class="label">p</span>:Number</code> &mdash; progress ratio (a value between 0 and 1 indicating the progress of the tween/ease)
</td></tr></table></p><p></p><span class="label">Returns</span><table cellpadding="0" cellspacing="0" border="0"><tr><td width="20"></td><td><code>Number</code> &mdash; translated number
</td></tr></table></div><br/><br/><hr><br/><p></p><center class="copyright"><footer></footer><br/>Thu Dec 20 2012, 04:30 PM -06:00 </center></div></body></html><!--<br/>Thu Dec 20 2012, 04:30 PM -06:00 -->