|
A for loop doesn't allow the screen to update until
it's finished.
you could try using setTimeout, or the DynAPI
thread object.
Completely untested, something like this might
work:
var hex = []; for(var i = 0;i < 10;i++) hex[i] = i; i = null; hex[10] = 'A'; hex[11] = 'B'; hex[12] = 'C'; hex[13] = 'D'; hex[14] = 'E'; hex[15] = 'F'; DynLayer.prototype.fade=function (color, steps) { var rgb, ptr; rgb = []; ptr = (color.indexOf('#')) ? 0 : 1; while(ptr < 6) { rgb[ptr >> 1] = parseInt(color.substr(ptr,2),16); ptr += 2; } color = this.getBgColor(); ptr = (color.indexOf('#')) ? 0 : 1; while(ptr < 6) { rgb[(ptr >> 1) + 3] = parseInt(color.substr(ptr,2),16); ptr += 2; } ptr = 0
if(ptr <= steps){ ptr++
setTimeout(this.toString()+'.doFade()',1)
}
} DynLayer.prototype.doFade=function (){
color = '#';
for(var i = 0; i < 3; i++){ color = color + hex[(rgb[3 + i] +
ptr * (rgb[0 + i] - rgb[3 + i])/steps) >> 4];
color = color + hex[(rgb[3 + i] + ptr * (rgb[0 + i] - rgb[3 + i])/steps) & 15]; }
this.setBgColor(color);
}
This won't work like this of course, as you need to
either declare hex[],rgb[] etc outside the function, or make them properties of
it. It's just demonstrating the setTimeout syntax.
I have a couple of fader examples from Il Maestro
here:
And here:
Although an IE5 only effect, the opacityanim widget
demonstrates the use of thread.js nicely.
Cheers,
Richard Bennett [EMAIL PROTECTED]
www.richardinfo.com (Everything running on, and ported to DynAPI2.53) visit the DynAPI homepage (and FAQ) :: http://dynapi.sourceforge.net/dynapi/index.php?menu=1 Browse (and search) the mailinglist here: http://www.mail-archive.com/index.php3?hunt=dynapi
|
- [Dynapi-Help] DynLayer.fade Roberto Pe�a
- Re: [Dynapi-Help] DynLayer.fade Richard Bennett
- Re: [Dynapi-Help] DynLayer.fade Roberto Pe�a
- Re: [Dynapi-Help] DynLayer.fade Roberto Pe�a
- Re: [Dynapi-Help] DynLayer.fade Nick Pelling
- Re: [Dynapi-Help] DynLayer.fade Richard Bennett
- Re: [Dynapi-Help] DynLayer.fade Roberto Pe�a
