/Bytex64.FX.js
if (typeof(Bytex64) == 'undefined') Bytex64 = {};
Bytex64.FX = {};
Bytex64.FX.version = 1.0;
Bytex64.FX.Effect = function(fx, secs) {
this.fx = fx;
this.secs = secs;
this.run = function() {
Bytex64.FX.run(this.fx, this.secs);
};
};
Bytex64.FX.ParallelEffect = function(fxs, secs) {
this.fx = function(p) {
for (i in fxs) {
fxs[i](p);
}
};
this.secs = secs;
this.run = function() {
Bytex64.FX.run(this.fx, this.secs);
};
};
Bytex64.FX.EffectChain = function(chain) {
this.chain = chain;
this.current = 0;
this.fx_current = function(p) {
this.chain[this.current].fx(p);
};
this.run = function() {
_this = this;
fx = function(p) {
_this.fx_current(p);
if (p == 1.0)
_this.run_next();
};
Bytex64.FX.run(fx, this.chain[this.current].secs);
};
this.run_next = function() {
this.current++;
if (this.current >= this.chain.length) {
this.current = 0;
return;
}
this.run();
};
};
Bytex64.FX.updateInterval = 50;
Bytex64.FX.run = function(fx, secs) {
secs = secs * 1000;
var interval;
var start = (new Date()).getTime();
fx(0.0);
interval = setInterval(function() {
var d = (new Date()).getTime() - start;
if (d >= secs) {
clearInterval(interval);
fx(1.0);
} else {
fx(d/secs);
}
}, Bytex64.FX.updateInterval);
}
Bytex64.FX.create = function(fx, secs) {
return function() {
Bytex64.FX.run(fx, secs);
}
}
Bytex64.FX.fadeIn = function(elem) {
return function(p) {
if (p == 0.0)
elem.style.display = 'block';
elem.style.opacity = p;
}
}
Bytex64.FX.fadeOut = function(elem) {
return function(p) {
elem.style.opacity = 1.0 - p;
if (p == 1.0)
elem.style.display = 'none';
}
}
/* vim: set ts=4 sts=4 sw=4 expandtab: */