3 Contains the basic animation logic to be extended by all other Fx Classes.
11 Implements: [Chain, Events, Options],
25 initialize: function(options){
26 this.subject = this.subject || this;
27 this.setOptions(options);
28 this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt();
29 var wait = this.options.wait;
30 if (wait === false) this.options.link = 'cancel';
33 getTransition: function(){
35 return -(Math.cos(Math.PI * p) - 1) / 2;
41 if (time < this.time + this.options.duration){
42 var delta = this.transition((time - this.time) / this.options.duration);
43 this.set(this.compute(this.from, this.to, delta));
45 this.set(this.compute(this.from, this.to, 1));
54 compute: function(from, to, delta){
55 return Fx.compute(from, to, delta);
59 if (!this.timer) return true;
60 switch (this.options.link){
61 case 'cancel': this.cancel(); return true;
62 case 'chain': this.chain(this.caller.bind(this, arguments)); return false;
67 start: function(from, to){
68 if (!this.check(from, to)) return this;
72 this.transition = this.getTransition();
79 if (this.stopTimer()) this.onComplete();
84 if (this.stopTimer()) this.onCancel();
89 this.fireEvent('start', this.subject);
92 onComplete: function(){
93 this.fireEvent('complete', this.subject);
94 if (!this.callChain()) this.fireEvent('chainComplete', this.subject);
98 this.fireEvent('cancel', this.subject).clearChain();
111 stopTimer: function(){
112 if (!this.timer) return false;
113 this.time = $time() - this.time;
114 this.timer = $clear(this.timer);
118 startTimer: function(){
119 if (this.timer) return false;
120 this.time = $time() - this.time;
121 this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
127 Fx.compute = function(from, to, delta){
128 return (to - from) * delta + from;
131 Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000};