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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.