PDA

View Full Version : Ultimate Fade In Slideshow 1.5 Opera bug



techywarrior
04-20-2007, 05:23 PM
1) Script Title: Ultimate Fade In Slideshow 1.5

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

3) Describe problem: The script doesn't do the fade in Opera 9. This will be a problem for any browser that uses the w3c opacity instead of the proprietary opacity filters/styles.

Here is the fix:
change

else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
to:

else if(typeof obj.tempobj.style.opacity)
obj.tempobj.style.opacity=obj.degree/101
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100

And change:


else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
to:

else if(typeof crossobj.style.opacity)
crossobj.style.opacity=this.degree/101
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100

jscheuer1
04-20-2007, 06:04 PM
Not quite. You need to check (for the benefit of IE 5 or 4) for support for filters when you check opacity. And, typeof is always true (even when it returns a string value of 'undefined') so:


else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101

and similarly for your other change or else any browser that doesn't support either IE filters or style.opacity will throw an error. The check for filters is needed only for a specific version of IE that doesn't support the alpha filter but thinks that it does support opacity when, it does not. Also, this was always wrong in the script and I never knew why it wasn't fixed:


else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101

Obviously, it should be 'this'. Notice, I put the check for opacity last, this is also important as, it will prevent any browser that can do one of the others from even trying opacity when, they might mistakenly think that they could use it.

Testing for opacity in this way also requires that the document.write part of the script actually includes opacity in the style for the two rotating divisions*.

I was on a campaign when the script first came out for DD to make these changes but, I never was able to get through. It would be a very nice improvement to an otherwise fantastic script.



*your method avoids this because:


else if (typeof crossobj.style.opacity)

is always true as long as crossobj.style exists. But, that makes it a faulty test. It might as well just be:


else

techywarrior
04-20-2007, 06:30 PM
Oops, the lines should be:

else if(typeof obj.tempobj.style.opacity != 'undefined')
and

else if(typeof crossobj.style.opacity != 'undefined')

They should however continue to be placed first since it is better that the browser use the w3c standard method then a proprietary one that it may also support.

jscheuer1
04-20-2007, 06:55 PM
They should however continue to be placed first since it is better that the browser use the w3c standard method then a proprietary one that it may also support.

That's debatable, I will leave that up to you but, with a true test like that, you still need to shield legacy browsers as indicated in my previous post. And, I believe the elements must still expressly be given inline style opacity in the document.write section of the script.

techywarrior
04-20-2007, 07:06 PM
That's debatable, I will leave that up to you but, with a true test like that, you still need to shield legacy browsers as indicated in my previous post. And, I believe the elements must still expressly be given inline style opacity in the document.write section of the script.

ok, well I don't plan on rewriting someone elses function but the changes I made covers 99.9+% of the users on my site so it will do for now. I believe that legacy browsers will still work the way the script is written. They will fail all of the checks and the script does an image swap with no fade effect.

jscheuer1
04-20-2007, 07:22 PM
I believe that legacy browsers will still work the way the script is written. They will fail all of the checks and the script does an image swap with no fade effect.

Nope. V 4 browsers, yes, except that they never even test for opacity. It gets tricky in the early to mid 5's with IE, perhaps others. But, you can do it any way you like.

BTW, the Swiss Army slide show can look just like this script, does incremental loading, and can also do much more while at the same time having none of these problems.

techywarrior
04-20-2007, 08:04 PM
BTW, the Swiss Army slide show can look just like this script, does incremental loading, and can also do much more while at the same time having none of these problems.

hehe, I see you just happened to have written the Swiss Army slide show. I was looking at that program for something else but my concept was shot down so I don't think I will get to impliment it. Does it allow variable speed?

jscheuer1
04-20-2007, 09:20 PM
hehe, I see you just happened to have written the Swiss Army slide show. I was looking at that program for something else but my concept was shot down so I don't think I will get to impliment it. Does it allow variable speed?

Well, if you want something done . . . very astute of you to notice. Sure, if you mean the pause between slides. It defaults to 3000 ms but, can be configured in either the call or as a property of the array.

The fade rate is hard coded but, it could (and has already in these forums) be easily changed or made into a configuration option. See:

http://www.dynamicdrive.com/forums/showthread.php?t=19403