keyboard
09-05-2012, 09:05 AM
Hello all!
I currently havae this code -
function fadeout(elem, time) {
elem = document.getElementById(elem);
var startOpacity = elem.style.opacity || 1;
elem.style.opacity = startOpacity;
(function go() {
elem.style.opacity -= startOpacity / (time / 100);
// for IE
elem.style.filter = 'alpha(opacity=' + elem.style.opacity * 100 + ')';
if(elem.style.opacity > 0) {
setTimeout(go, 100);
} else {
elem.visible = 'false';
}
})();
}
Which I'd like to convert so I also have a fadein() function, but not sure how :\
Any tips (Yes, I know you can do this with jquery, I'm trying to avoid that).
Also, is there any way to make the fade smoother?
keyboard1333
I currently havae this code -
function fadeout(elem, time) {
elem = document.getElementById(elem);
var startOpacity = elem.style.opacity || 1;
elem.style.opacity = startOpacity;
(function go() {
elem.style.opacity -= startOpacity / (time / 100);
// for IE
elem.style.filter = 'alpha(opacity=' + elem.style.opacity * 100 + ')';
if(elem.style.opacity > 0) {
setTimeout(go, 100);
} else {
elem.visible = 'false';
}
})();
}
Which I'd like to convert so I also have a fadein() function, but not sure how :\
Any tips (Yes, I know you can do this with jquery, I'm trying to avoid that).
Also, is there any way to make the fade smoother?
keyboard1333