From fde0715f4ef337f190c1c0cf972065bb82e096db Mon Sep 17 00:00:00 2001 From: pgiraud Date: Fri, 29 Feb 2008 07:31:56 +0000 Subject: [PATCH] add the Quad easing methods for Tween git-svn-id: http://svn.openlayers.org/trunk/openlayers@6415 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Tween.js | 48 +++++++++++++++++++++++++++++++++++++++++ tests/manual/tween.html | 1 + 2 files changed, 49 insertions(+) diff --git a/lib/OpenLayers/Tween.js b/lib/OpenLayers/Tween.js index b5e0407be0..fca8cbb981 100644 --- a/lib/OpenLayers/Tween.js +++ b/lib/OpenLayers/Tween.js @@ -268,3 +268,51 @@ OpenLayers.Easing.Expo = { CLASS_NAME: "OpenLayers.Easing.Expo" }; + +/** + * Namespace: OpenLayers.Easing.Quad + */ +OpenLayers.Easing.Quad = { + + /** + * Function: easeIn + * + * Parameters: + * t - {Float} time + * b - {Float} beginning position + * c - {Float} total change + * d - {Float} duration of the transition + */ + easeIn: function(t, b, c, d) { + return c*(t/=d)*t + b; + }, + + /** + * Function: easeOut + * + * Parameters: + * t - {Float} time + * b - {Float} beginning position + * c - {Float} total change + * d - {Float} duration of the transition + */ + easeOut: function(t, b, c, d) { + return -c *(t/=d)*(t-2) + b; + }, + + /** + * Function: easeInOut + * + * Parameters: + * t - {Float} time + * b - {Float} beginning position + * c - {Float} total change + * d - {Float} duration of the transition + */ + easeInOut: function(t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t + b; + return -c/2 * ((--t)*(t-2) - 1) + b; + }, + + CLASS_NAME: "OpenLayers.Easing.Quad" +}; diff --git a/tests/manual/tween.html b/tests/manual/tween.html index 4c2fa8ebbb..af677aa331 100644 --- a/tests/manual/tween.html +++ b/tests/manual/tween.html @@ -65,6 +65,7 @@