PDA

View Full Version : Help adapting script



lukinhasb
08-18-2011, 06:49 PM
Hello,

There's this Gradual Element Fader (http://www.dynamicdrive.com/dynamicindex11/gradualfader.htm) script

This looks silly, but I've tried here and couldn't do...

I want to invert the way the script works, like:

Original script:


Image with 40% opacity -> mouseover = Image with 100% opacity

I want to make it from 100% to 40%, Intended script:


Image with 100% opacity -> mouseover = Image with 40% opacity

I would gladly accept some suggestions on how to do it *-*

Thanks in advance :D

Minos
08-18-2011, 07:05 PM
In the .js file, at the bottom, try swapping

targetobjects[i].onmouseover=function(e){gradualFader.fadeinterface(this, e, "fadeup")}
targetobjects[i].onmouseout=function(e){gradualFader.fadeinterface(this, e, "fadedown")}

with

targetobjects[i].onmouseover=function(e){gradualFader.fadeinterface(this, e, "fadedown")}
targetobjects[i].onmouseout=function(e){gradualFader.fadeinterface(this, e, "fadeup")}

That won't completely do it, if I'm thinking correctly it will start off with the low opacity but if you mouseover and then mouseout it will do what you are asking.

I think. Let me know if that is the case.

ggalan
08-18-2011, 07:14 PM
try this,

lukinhasb
08-18-2011, 07:33 PM
It almost worked.

Just don't work in Internet Explorer:

http://i55.tinypic.com/2ldw1es.jpg

Live demo of the problem:

http://criatweb.com.br/gigbr/light/

ggalan
08-18-2011, 08:41 PM
just checked on IE9 and it worked, which version are you having problems with?

lukinhasb
08-18-2011, 08:50 PM
Crapnet Explorer 8

ggalan
08-18-2011, 11:34 PM
hmm, i only have ie9 on my machine, will try to find a way to test on ie8

you might want to play with these numbers, it says ie6 but might affect other versions of ie


gradualFader.setopacity=function(obj, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
var targetobject=obj
if (targetobject && targetobject.filters && targetobject.filters[0]){ //IE syntax
if (typeof targetobject.filters[0].opacity=="number") //IE6
targetobject.filters[0].opacity=value*100
else //IE 5.5
targetobject.style.filter="alpha(opacity="+value*100+")"
}
else if (targetobject && typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
targetobject.style.MozOpacity=value
else if (targetobject && typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
targetobject.style.opacity=value
targetobject.currentopacity=value
}

jscheuer1
08-19-2011, 01:28 AM
In IE less than 9 there's a conflict between the alpha opacity filter and .png images saved with alpha channel opacity. Since you know the background color, you could save the image with that instead of making it alpha channel transparent. Then it should work in IE less than 9:

4028