...

View Full Version : opacity



crmpicco
04-14-2005, 03:47 PM
http://www.clagnut.com/sandbox/imagefades/



function setOpacity(obj, opacity) {
opacity = (opacity == 100)?99.999:opacity;

// IE/Win
obj.style.filter = "alpha(opacity:"+opacity+")";

// Safari<1.2, Konqueror
obj.style.KHTMLOpacity = opacity/100;

// Older Mozilla and Firefox
obj.style.MozOpacity = opacity/100;

// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity <= 100) {
setOpacity(obj, opacity);
opacity += 75; // the level of darkness (100 - high, 0 - low)
window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
}
}
}

function initImage() {
imageId = 'thephoto';
image = document.getElementById(imageId);
setOpacity(image, 0);
image.style.visibility = 'visible';
fadeIn(imageId,0);
}


window.onload = function() {initImage()}
document.write("<style type='text/css'>#thephoto {visibility:hidden;} </style>");


Can anyone see a way to speed up the change from my original image to the white image?

The opacity?

Kor
04-14-2005, 05:02 PM
not very clear to me... To change the speed you may increase the rate of substract and/or to decrease the rate of setTimeout function. Anyway, for the latest, for almost all the browsers the rate under 70 miliseconds will have no effect.

Anyway I guess that you should also include a clearTimeout() function when the opacity turns to 0, to avoid unecessary math underground calculation

hemebond
04-14-2005, 11:03 PM
window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum