My plan was to create a dynamic effect where a browser-sized div
would rotate through 3 different backgrounds using jQuery's fading effect. However, I encountered an issue - whenever I resize the browser window, the effect restarts from the beginning instead of continuing smoothly. I'm specifically facing this problem in Chrome version 37. Any guidance or suggestions on how to address this would be greatly appreciated.
HTML
<div class="wrap">
<div class="wrapinside" style="background: url(1.jpg) no-repeat center center;"></div>
<div class="wrapinside" style="background: url(2.jpg) no-repeat center center;"></div>
<div class="wrapinside" style="background: url(3.jpg) no-repeat center center;"></div>
</div>
jQuery
$(window).load(function(){
$('div.wrapinside').hide();
var dg_H = $(window).height();
var dg_W = $(window).width();
$('.wrap').css({'height':dg_H,'width':dg_W});
function anim() {
$(".wrap div.wrapinside").first().appendTo('.wrap').fadeOut(3000);
$(".wrap div").first().fadeIn(3000);
setTimeout(anim, 6000);
}
anim();})
$(window).resize(function(){window.location.href=window.location.href})
CSS
.wrap {
position: fixed;
z-index: -1;
top: 0;
left: 0;
background: #000;
}
.wrap div.wrapinside {
position: absolute;
top: 0;
display: none;
width: 100%;
height: 100%;
z-index: -1;
background-size: cover;
}