Path: blob/trunk/third_party/closure/goog/fx/easing.js
2868 views
// Copyright 2006 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Easing functions for animations.16*17* @author [email protected] (Erik Arvidsson)18*/1920goog.provide('goog.fx.easing');212223/**24* Ease in - Start slow and speed up.25* @param {number} t Input between 0 and 1.26* @return {number} Output between 0 and 1.27*/28goog.fx.easing.easeIn = function(t) {29return goog.fx.easing.easeInInternal_(t, 3);30};313233/**34* Ease in with specifiable exponent.35* @param {number} t Input between 0 and 1.36* @param {number} exp Ease exponent.37* @return {number} Output between 0 and 1.38* @private39*/40goog.fx.easing.easeInInternal_ = function(t, exp) {41return Math.pow(t, exp);42};434445/**46* Ease out - Start fastest and slows to a stop.47* @param {number} t Input between 0 and 1.48* @return {number} Output between 0 and 1.49*/50goog.fx.easing.easeOut = function(t) {51return goog.fx.easing.easeOutInternal_(t, 3);52};535455/**56* Ease out with specifiable exponent.57* @param {number} t Input between 0 and 1.58* @param {number} exp Ease exponent.59* @return {number} Output between 0 and 1.60* @private61*/62goog.fx.easing.easeOutInternal_ = function(t, exp) {63return 1 - goog.fx.easing.easeInInternal_(1 - t, exp);64};656667/**68* Ease out long - Start fastest and slows to a stop with a long ease.69* @param {number} t Input between 0 and 1.70* @return {number} Output between 0 and 1.71*/72goog.fx.easing.easeOutLong = function(t) {73return goog.fx.easing.easeOutInternal_(t, 4);74};757677/**78* Ease in and out - Start slow, speed up, then slow down.79* @param {number} t Input between 0 and 1.80* @return {number} Output between 0 and 1.81*/82goog.fx.easing.inAndOut = function(t) {83return 3 * t * t - 2 * t * t * t;84};858687