Show and hide image the smooth way ?

J

jesper_lofgren

Hi,

I wonder if its possible to show and hide a image with javascipt.

I want the image to disapear from bottom and up very smooth, maybe
under 3-4sec.

Is it possible ? any tips ?

Thanks
Jes
 
M

marss

Hi,

I wonder if its possible to show and hide a image with javascipt.

I want the image to disapear from bottom and up very smooth, maybe
under 3-4sec.

Is it possible ? any tips ?

Thanks
Jes

Solution for IE.

<html>
<head>
<script type="text/javascript">
function hideImage()
{
document.getElementById("container").filters[0].Apply();
document.getElementById("im1").style.visibility="hidden";
document.getElementById("container").filters[0].Play();
}
</script>
</head>
<body>
<DIV ID="container"
STYLE="height:200px;width:200px;filter:progid:DXImageTransform.Microsoft.Barn(orientation=horizontal,
motion=in)">
<img id='im1' src="1.jpg" STYLE="height:200px;width:200px">
</DIV>
<BUTTON onclick="hideImage()">Hide image</BUTTON>
</body>
</html>

More information about visual filters:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/filter/reference/reference.asp
 
A

ASM

(e-mail address removed) a écrit :
I want the image to disapear from bottom and up very smooth, maybe
under 3-4sec.

Is it possible ? any tips ?


Example :

<html>
<script type="text/javascript">
function $(id) { return (typeof(id)=='string')?
document.getElementById(id) : id; }
function fadder(what, opacity, sens, duration)
{
what = $(what);
opacity = (opacity == 100)? 99.999 : opacity;
// IE/Win
what.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
what.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
what.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
what.style.opacity = opacity/100
if(sens>0 && opacity<99 || sens<0 && opacity>0)
{
opacity += 1*sens;
setTimeout(
function(){fadder(what, opacity, sens, duration);}
,duration);
}
else
{
$('show').style.display=$('show').style.display==''?'none':'';
$('hid').style.display=$('hid').style.display==''?'none':'';
}
}
</script>
In onclick of button play with duration : here = 150<br>

<img src="asm1.gif" alt="" id="pict" />
<button id="show"
onclick="fadder('pict', 1, 1, 150);"
style="display:none">show</button>
<button id="hid"
onclick="fadder('pict', 98, -1, 150);">hide</button>
</html>
 
P

Peter Michaux

ASM said:
// Safari<1.2, Konqueror
what.style.KHTMLOpacity = opacity/100;

I talked with some guys on irc #kde and apparently Konq has never
supported opacity yet. The development version of Konq for KDE4
supports just plain "opacity". So the fact that it is "KHTMLOpacity" is
just confusing since I think only Safari (khtml based) has used this
property.

Peter
 
A

ASM

Peter Michaux a écrit :
I talked with some guys on irc #kde and apparently Konq has never
supported opacity yet. The development version of Konq for KDE4
supports just plain "opacity". So the fact that it is "KHTMLOpacity" is
just confusing since I think only Safari (khtml based) has used this
property.

I'm not really sure Safari uses it ... (in all cases Safari 1.3 doesn't)
 
P

Peter Michaux

ASM said:
Peter Michaux a écrit :

I'm not really sure Safari uses it ... (in all cases Safari 1.3 doesn't)

A little googling makes it look like early Safari does.

Also I think it is "KhtmlOpacity" but I don't know because different
people list it different ways. I would really like to know and test it
on Safari 1.1.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top