Last active
December 27, 2015 22:59
-
-
Save mezbahalam/7402276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Opacity Sample</title> | |
<style> | |
.gallery {display:none;} | |
</style> | |
<script> | |
function Gid(id) { | |
return document.getElementById(id); | |
} | |
var CurrentImg = 0; | |
/* | |
opac is a value from 0 - 100. A lower value makes | |
the element more transparent. | |
*/ | |
var Fade = function () { | |
var o, opac, delta, TimerId = false, OnDone; | |
function OnTimer() { | |
if (TimerId) | |
clearTimeout(TimerId); | |
TimerId = false; | |
if (o == null) | |
return; | |
o.style.opacity = opac; | |
opac += delta; | |
if (delta > 0 ? opac < 1 : opac > 0) | |
TimerId = setTimeout(OnTimer, 100); | |
else if (typeof OnDone == "function") | |
OnDone(); | |
} | |
return function (id, FadeOut, OnDone_) { | |
delta = 0.1; opac = 0; | |
OnDone = OnDone_; | |
if (FadeOut) { | |
opac = 1; delta *= -1; | |
} | |
o = Gid(id); | |
OnTimer(); | |
} | |
}(); | |
function OnFini () { | |
var id = "I" + CurrentImg; | |
if (Gid(id) != null) | |
Gid(id).style.display = "none"; | |
CurrentImg++; | |
id = "I" + CurrentImg; | |
if (Gid(id) == null) | |
id = "I" + (CurrentImg = 1); | |
Gid(id).style.display = "inline"; | |
Fade(id, false); | |
} | |
function OnNext() { | |
var id = "I" + CurrentImg; | |
if (Gid(id) != null) | |
Fade(id, true, OnFini); | |
} | |
</script> | |
</head> | |
<body onload="OnFini()"> | |
<!-- | |
<button onclick="Fade('I1',true)">Fade Out</button> | |
<button onclick="Fade('I1',false)">Fade In</button><br> | |
--> | |
<table align='center'><tr><td align='center'> | |
<button onclick="OnNext()">Next</button> | |
</td></tr> | |
<tr><td align='center'> | |
<img id="I1" class="gallery" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc1/c13.12.155.155/s100x100/374448_539793346087578_1939199766_a.jpg"/><br> | |
<img id="I2" class="gallery" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/c52.0.90.90/935651_101910783350174_556838103_n.jpg"/><br> | |
<img id="I3" class="gallery" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c32.9.117.117/s100x100/1002495_552379128154792_1356676700_a.jpg"/> | |
<div id="I4" class="gallery"><big><big>End of the Show!</big></big></div> | |
</td></tr></table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment