John,
Ok, I'll admit your coding level is far superior to mine, but here's what I've got working...
live:
www.justrpics.com/youngfamily & choose a gallery
javascript function:
Code:
//change the opacity for different browsers
function changeOpac(o, id) {
if(o==0||o==100)
clearTimeout(changeOpac.t);
var object = document.getElementById(id).style;
if(changeOpac.m=='ie')
object.filter = "alpha(opacity=" + o + ")";
else if(changeOpac.m)
object[changeOpac.m] = (o / 100);
}
;(function(){
if(typeof changeOpac.m=='undefined'){
var e=document.documentElement, t=function(s){return typeof e.style[s]=='string';};
changeOpac.m=e.filters? 'ie' : t('opacity')? 'opacity' : t('MozOpacity')? 'MozOpacity' : t('KhtmlOpacity')? 'KhtmlOpacity' : null;
}})();
function fadeImage(inORout, stOp, toOp, speed, ease, when, delay, dur, imageid){
// Definitions for function variables
// inORout - set the fade to in or out
// stOp - set the start opacity for the fade
// toOp - set the ending opacity
// speed - set speed for the fade to be completed 1=slow - 10=fast
// ease - set the level of the fade slowing 1=light - 5=strong
// when - set when the fade will begin to ease 1=sooner - 50=later
// delay - set a delay or pause for the fade 0=nodelay - 5=longdelay
// dur - set the duration of the fade 10=shorter - 20=longer
clearTimeout(changeOpac.t);
speed = speed*2;
var timer = 0;
o = stOp;
if(inORout == 'in'){
setTimeout(function(){
//fade in new image
for(i = stOp; i <= toOp; i++) {
if (o <= when){
o += (((toOp-o)/(25))*speed)/(ease/2);
}else{
o += (((toOp-o)/(100))*speed)/(ease);
}
changeOpac.t=setTimeout("changeOpac(" + o + ",'" + imageid + "')",(timer * dur));
timer++;
}
},(delay*100));
}
if(inORout == 'out'){
setTimeout(function(){
//fade in new image
for(i = stOp; i >= toOp; i--) {
if (o >= when){
o -= (((o-toOp)/(25))*speed)/(ease/2);
}else{
o -= (((o-toOp)/(100))*speed)/(ease);
}
changeOpac.t=setTimeout("changeOpac(" + o + ",'" + imageid + "')",(timer * dur));
timer++;
}
},(delay*100));
}
}
Let me know what you think and if you can make any improvements for me..
Bookmarks