Announcement

Collapse
No announcement yet.

Animated Background jQuery using too much resources

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Animated Background jQuery using too much resources

    Need some help will this. I got this script that I copied and used this on my client's Joomla site. The script stretch the image and one at a time it fades and shows the next image

    Code:
    	<div id="wrap">
    <img class="bgfade" src="/web2/images/bg.png" alt="" /> 
    <img class="bgfade" src="/web2/images/bg1.png" alt="" /> 
    <img class="bgfade" src="/web2/images/bg2.png" alt="" />
    <img class="bgfade" src="/web2/images/bg1.png" alt="" /> 
    </div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
    <script type="text/javascript">
    $(window).load(function(){
    $('img.bgfade').hide();
    var dg_H = $(window).height();
    var dg_W = $(window).width();
    $('#wrap').css({'height':dg_H,'width':dg_W});
    function anim() {
        $("#wrap img.bgfade").first().appendTo('#wrap').fadeOut(1500);
        $("#wrap img").first().fadeIn(1500);
        setTimeout(anim, 3000);
    }
    anim();})
    $(window).resize(function(){window.location.href=window.location.href})</script>
    with this CSS

    Code:
    #wrap{
      position:fixed;; 
      z-index:-1; 
      top:0; 
      left:0; 
      background-color:black
    }
    #wrap img.bgfade{
      position:absolute;
      top:0;
      display:none;
      width:100%;
      height:100%;
      z-index:-1
    }
    It work well but everytime I resize a window or use with my formMail (BreezingForm) I get an "Internal Server Error"

    I hope somebody can help me reduce the resource usage of this script. Or recommend a better way of doing this.
Working...
X