Jump to content


Photo

Page Banner


  • Please log in to reply
No replies to this topic

#1 White_Lily

White_Lily

    Advanced Member

  • Members
  • PipPipPip
  • 523 posts

Posted 04 December 2013 - 06:52 AM

I have been asked to produce code that make a banner fade through a set of images, but in between fading the images need to slide a little bit. I have produced this:

 

<script type="text/javascript">
$("#banner-images > img:eq(0)").show();
var box_height = 249,
      img_height = $("#banner-images > img:eq(0)").outerHeight(true),
      calc_bottom = ((img_height - box_height) - 30);
$("#banner-caption").html($("#banner-images > img:eq(0)").attr("title"));
$("#banner-images > img:eq(0)").animate({bottom: "-" + calc_bottom + "px"}, 5000);
setInterval(function(){
      $("#banner-images > img:eq(0)").fadeOut(1000);
      $("#banner-images > img:eq(0)").appendTo("#banner-images");
      $("#banner-images > img:eq(0)").fadeIn(1000, function(){
            $("#banner-caption").html($(this).attr("title"));
            var img_height = $(this).outerHeight(true),
                  calc_bottom = ((img_height - box_height) - 30);
                  $("#banner-images > img").css({bottom: "0px"});
            $(this).animate({bottom: "-" + calc_bottom + "px"}, 4000);
      });
}, 5000);
</script>

 

The problem I have is that when you first go onto the page, the first image slides down fine, and then the rest follows suit. However if you click the refresh button on your browser ( or hit F5 ) the code seems to skip the animation of the first image completely and just straight into the second image.

 

Any ideas as to why this is, and how to fix it would be much appreciated.


"In order to be irreplaceable, one needs to be different from another."





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com