Jump to content

Page Banner


White_Lily

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/284518-page-banner/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.