3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
9 // shortcuts to aid compression
17 Ext.apply(EXTLIB.Easing, {
19 easeBoth: function (t, b, c, d) {
20 return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b;
23 easeInStrong: function (t, b, c, d) {
24 return c * (t /= d) * t * t * t + b;
27 easeOutStrong: function (t, b, c, d) {
28 return -c * ((t = t / d - 1) * t * t * t - 1) + b;
31 easeBothStrong: function (t, b, c, d) {
32 return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b;
35 elasticIn: function (t, b, c, d, a, p) {
36 if (t == 0 || (t /= d) == 1) {
37 return t == 0 ? b : b + c;
43 s = p / (2 * pi) * asin(c / a);
49 return -(a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b;
53 elasticOut: function (t, b, c, d, a, p) {
54 if (t == 0 || (t /= d) == 1) {
55 return t == 0 ? b : b + c;
61 s = p / (2 * pi) * asin(c / a);
67 return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b;
70 elasticBoth: function (t, b, c, d, a, p) {
71 if (t == 0 || (t /= d / 2) == 2) {
72 return t == 0 ? b : b + c;
75 p = p || (d * (.3 * 1.5));
79 s = p / (2 * pi) * asin(c / a);
86 -.5 * (a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b :
87 a * pow(2, -10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p) * .5 + c + b;
90 backIn: function (t, b, c, d, s) {
92 return c * (t /= d) * t * ((s + 1) * t - s) + b;
96 backOut: function (t, b, c, d, s) {
100 return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
104 backBoth: function (t, b, c, d, s) {
107 return ((t /= d / 2 ) < 1) ?
108 c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b :
109 c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
113 bounceIn: function (t, b, c, d) {
114 return c - EXTLIB.Easing.bounceOut(d - t, 0, c, d) + b;
118 bounceOut: function (t, b, c, d) {
119 if ((t /= d) < (1 / 2.75)) {
120 return c * (7.5625 * t * t) + b;
121 } else if (t < (2 / 2.75)) {
122 return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
123 } else if (t < (2.5 / 2.75)) {
124 return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
126 return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
130 bounceBoth: function (t, b, c, d) {
132 EXTLIB.Easing.bounceIn(t * 2, 0, c, d) * .5 + b :
133 EXTLIB.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
139 var EXTLIB = Ext.lib;
141 EXTLIB.Anim.color = function(el, args, duration, easing, cb, scope) {
142 return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.ColorAnim);
145 EXTLIB.ColorAnim = function(el, attributes, duration, method) {
146 EXTLIB.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
149 Ext.extend(EXTLIB.ColorAnim, EXTLIB.AnimBase);
151 var superclass = EXTLIB.ColorAnim.superclass,
153 transparentRE = /^transparent|rgba\(0, 0, 0, 0\)$/,
154 rgbRE = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
155 hexRE= /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
156 hex3RE = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
158 return typeof v !== 'undefined';
162 function parseColor(s) {
172 Ext.each([hexRE, rgbRE, hex3RE], function(re, idx){
173 base = (idx % 2 == 0) ? 16 : 10;
175 if(c && c.length == 4){
176 out = [pi(c[1], base), pi(c[2], base), pi(c[3], base)];
183 Ext.apply(EXTLIB.ColorAnim.prototype, {
184 getAttr : function(attr) {
188 if(colorRE.test(attr)){
189 while(el && transparentRE.test(val = Ext.fly(el).getStyle(attr))){
194 val = superclass.getAttr.call(me, attr);
199 doMethod : function(attr, start, end) {
207 if(colorRE.test(attr)){
211 for(i = 0, len = start.length; i < len; i++) {
213 val[i] = superclass.doMethod.call(me, attr, v, end[i]);
215 val = 'rgb(' + floor(val[0]) + ',' + floor(val[1]) + ',' + floor(val[2]) + ')';
217 val = superclass.doMethod.call(me, attr, start, end);
222 setRunAttr : function(attr) {
224 a = me.attributes[attr],
229 superclass.setRunAttr.call(me, attr);
230 ra = me.runAttrs[attr];
231 if(colorRE.test(attr)){
232 var start = parseColor(ra.start),
233 end = parseColor(ra.end);
235 if(!isset(to) && isset(by)){
236 end = parseColor(by);
237 for(var i=0,len=start.length; i<len; i++) {
238 end[i] = start[i] + end[i];
251 var EXTLIB = Ext.lib;
252 EXTLIB.Anim.scroll = function(el, args, duration, easing, cb, scope) {
253 return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.Scroll);
256 EXTLIB.Scroll = function(el, attributes, duration, method) {
258 EXTLIB.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
262 Ext.extend(EXTLIB.Scroll, EXTLIB.ColorAnim);
264 var superclass = EXTLIB.Scroll.superclass,
267 Ext.apply(EXTLIB.Scroll.prototype, {
269 doMethod : function(attr, start, end) {
272 curFrame = me.curFrame,
273 totalFrames = me.totalFrames;
276 val = [me.method(curFrame, start[0], end[0] - start[0], totalFrames),
277 me.method(curFrame, start[1], end[1] - start[1], totalFrames)];
279 val = superclass.doMethod.call(me, attr, start, end);
284 getAttr : function(attr) {
287 if (attr == SCROLL) {
288 return [me.el.scrollLeft, me.el.scrollTop];
290 return superclass.getAttr.call(me, attr);
294 setAttr : function(attr, val, unit) {
298 me.el.scrollLeft = val[0];
299 me.el.scrollTop = val[1];
301 superclass.setAttr.call(me, attr, val, unit);