Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[javascript] DHTML image animation
#1
Credits and Source: http://jsmadeeasy.com/

Name: DHTML image animation
Description: Enhances your image presentation with a smooth dynamic motion (fade-in-fade-out). Great to bring your images alive! Loads much faster than any gif-animations. Easy to configure.
Snippet:


Insert into <HEAD>
Code:
<script language=javaScript>
<!-- Beginning of JavaScript -

sandra0 = new Image();
sandra0.src = "sandraaa0.jpg";

sandra1 = new Image();
sandra1.src = "sandraaa1.jpg";

sandra2 = new Image();
sandra2.src = "sandraaa2.jpg";

var i_strngth=1
var i_image=0

var imageurl = new Array()
imageurl[0] ="sandraaa0.jpg"
imageurl[1] ="sandraaa1.jpg"
imageurl[2] ="sandraaa2.jpg"


function showimage() {
    if(document.all) {
        if (i_strngth <=110) {
            testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
            i_strngth=i_strngth+10
            var timer=setTimeout("showimage()",100)
        }
        else {
            clearTimeout(timer)
            var timer=setTimeout("hideimage()",1000)
        }
    }

    if(document.layers) {
            clearTimeout(timer)
            document.testimage.document.write("<img src="+imageurl[i_image]+" border=0>")
            document.close()
            i_image++
            if (i_image >= imageurl.length) {i_image=0}
            var timer=setTimeout("showimage()",2000)

    }
}


function hideimage() {
    if (i_strngth >=-10) {
        testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
        i_strngth=i_strngth-10
        var timer=setTimeout("hideimage()",100)
    }
    else {
        clearTimeout(timer)
        i_image++
        if (i_image >= imageurl.length) {i_image=0}
        i_strngth=1
        var timer=setTimeout("showimage()",500)
    }
}


// - End of JavaScript - -->
</script>

Insert into <BODY>
Code:
<body bgcolor="#FFFFFF" onLoad="showimage()">

<div id="mainbod" style="position:absolute;visibility:visible;top:50px;left:360px;">
</div>

<div id="testimage" style="position:absolute;visibility:visible;top:50px;left:40px"></div>

Thats It Smile
Thankyou for reading
Reply
#2
Thanks for all the Snippets, Much Appreciated.
Reply
#3
(11-06-2009, 07:19 AM)Fail Ninja Wrote: Thanks for all the Snippets, Much Appreciated.

I appreciated what you have said. Be happy always. Thanks Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Free Worker HTML, CSS, Javascript ImFocuzz 2 1,098 04-05-2014, 10:01 PM
Last Post: VHPanda
  Problems with PNG Animation Mark Topper 1 611 07-14-2012, 05:36 PM
Last Post: 'Snorlax
  Can I get such css3 animation to work in Internet Explorer, Opera, and such browsers? Mark Topper 1 732 07-14-2012, 05:26 PM
Last Post: 'Snorlax
  [MyBBError Message] PLEASE HELP ME!! Enable Javascript Registration Error iRun 4 1,637 01-26-2012, 03:13 PM
Last Post: iRun
  Image ontop of Image? rlogin 3 793 07-11-2011, 02:56 PM
Last Post: Billy Mays

Forum Jump:


Users browsing this thread: 1 Guest(s)