From e75fa26b095963968834bc75208ea174e8718167 Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Tue, 30 Jun 2009 12:32:20 +1000 Subject: [PATCH] 0.8.2 Fix for linear easing --- raphael.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/raphael.js b/raphael.js index 70fb3b9..7a874da 100644 --- a/raphael.js +++ b/raphael.js @@ -2483,8 +2483,8 @@ window.Raphael = (function () { }; R.easing_formulas = { - linear: function( time, beg, diff, dur ) { - return beg + diff * time; + linear: function (time, beg, diff, dur) { + return time / dur; }, "<": function (time, beg, diff, dur) { return diff * (time /= dur) * time + beg; @@ -2508,6 +2508,28 @@ window.Raphael = (function () { } else { return diff * (7.5625 * (time -= (2.625 / 2.75)) * time + .984375) + beg; } + }, + elastic: function (time, beg, diff, dur) { + var s = 1.70158, + p = 0, + s, + a = diff; + if (time == 0) { + return beg; + } + if ((time /= dur) == 1) { + return beg + diff; + } + if (!p) { + p = dur * .3; + } + if (a < Math.abs(diff)) { + a = diff; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(diff / a); + } + return a * Math.pow(2, -10 * time) * Math.sin((time * dur - s) * (2 * Math.PI) / p) + diff + beg; } }; -- 2.39.2