Debian Codegraph @

closure-library/closure/goog/fx/easing.js

raw
1 // Copyright 2006 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Easing functions for animations.
17 *
18 * @author [email protected] (Erik Arvidsson)
19 */
20
21 goog.provide('goog.fx.easing');
22
23
24 /**
25 * Ease in - Start slow and speed up.
26 * @param {number} t Input between 0 and 1.
27 * @return {number} Output between 0 and 1.
28 */
29 goog.fx.easing.easeIn = function(t) {
30 return goog.fx.easing.easeInInternal_(t, 3);
31 };
32
33
34 /**
35 * Ease in with specifiable exponent.
36 * @param {number} t Input between 0 and 1.
37 * @param {number} exp Ease exponent.
38 * @return {number} Output between 0 and 1.
39 * @private
40 */
41 goog.fx.easing.easeInInternal_ = function(t, exp) {
42 return Math.pow(t, exp);
43 };
44
45
46 /**
47 * Ease out - Start fastest and slows to a stop.
48 * @param {number} t Input between 0 and 1.
49 * @return {number} Output between 0 and 1.
50 */
51 goog.fx.easing.easeOut = function(t) {
52 return goog.fx.easing.easeOutInternal_(t, 3);
53 };
54
55
56 /**
57 * Ease out with specifiable exponent.
58 * @param {number} t Input between 0 and 1.
59 * @param {number} exp Ease exponent.
60 * @return {number} Output between 0 and 1.
61 * @private
62 */
63 goog.fx.easing.easeOutInternal_ = function(t, exp) {
64 return 1 - goog.fx.easing.easeInInternal_(1 - t, exp);
65 };
66
67
68 /**
69 * Ease out long - Start fastest and slows to a stop with a long ease.
70 * @param {number} t Input between 0 and 1.
71 * @return {number} Output between 0 and 1.
72 */
73 goog.fx.easing.easeOutLong = function(t) {
74 return goog.fx.easing.easeOutInternal_(t, 4);
75 };
76
77
78 /**
79 * Ease in and out - Start slow, speed up, then slow down.
80 * @param {number} t Input between 0 and 1.
81 * @return {number} Output between 0 and 1.
82 */
83 goog.fx.easing.inAndOut = function(t) {
84 return 3 * t * t - 2 * t * t * t;
85 };