White_Lily Posted December 4, 2013 Share Posted December 4, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/284518-page-banner/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.