我有以下脚本,我希望它在动画的最后一次移动后停止移动,而只是闪烁/重复。我尝试添加 .stop 但运气不佳:
JS:
<script type="text/javascript">
$(window).scroll( function() {
if ( $(window).scrollTop() > 0 ) {
loadDiv();
}
});
function loadDiv() {
$('#container-holder').fadeIn('slow', function() {
$(this).fadeTo("slow", 1);
$('#container, #imagetest1').fadeTo("slow", 1);
$('#imagetest1').delay(30).animate({'margin-top': '0'}, {duration:0, queue:true});
$('#imagetest1').delay(30).animate({'margin-top': '-78px'}, {duration:0, queue:true});
$('#imagetest1').delay(30).animate({'margin-top': '-156px'}, {duration:0, queue:true});
$('#imagetest1').delay(30).animate({'margin-top': '-234px'}, {duration:0, queue:true});
$('#imagetest1').delay(30).animate({'margin-top': '-312px'}, {duration:0, queue:true});
});
}
</script>
CSS:
<style>
#background {
width: 200px;
height: 1000px;
border: 1px solid #999;
}
#container-holder {
width: 200px;
height: 200px;
border: 1px solid #999;
visibility: visible;
margin-top: 100px;
}
#container {
width: 160px;
height: 160px;
background-color: #333f;
border: 1px solid #333f;
}
#imagetest1 {
width: 162px;
height: 390px;
background-image: url('http://i811.photobucket.com/albums/zz40/mjl-admin/rainbow.jpg');
border: 1px solid green;
}
#image-container {
width: 10px;
height: 10px;
}
#image1 {
width: 165px;
height: 78px;
background-color: #fff;
overflow: hidden;
}
</style>
HTML:
<div id="background">
<div id="container-holder">
<div id="container">
<div id="image1"><div id="imagetest1"></div></div>
</div>
</div>
</div>
小提琴:http: //jsfiddle.net/fatfrank44/bwbEu/9/