不好意思。jQuery动画回调
我发现了一段代码,并将其改变了很多,它似乎有用。
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('dota').click(function(){
});
$('#Homebutton').toggle(function(){
$('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');
$('.animateme').animate({
left: '+=150',
}, 800, function() {
$('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />');
});
$('.animateme').animate({
left: '+=0',
}, 500);
$('#Homebutton').html('<img src="Construct2/Images/buttonred.png" />');
$('.animateme').animate({
left: '+=0',
}, 500, function() {
$('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
});
}, function(){
$('.animateme').html('<img src="Construct2/Images/Gnoll_Running_left.gif" />');
$('.animateme').animate({
left: '-=500',
}, 2200, function() {
$('.animateme').html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
});
});
$('#AddOnbutton').toggle(function(){
$('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');
$('.animateme').animate({
left: '+=250',
}, 1000, function() {
$('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />')
});
$('.animateme').animate({
left: '+=0',
}, 1000, function() {
$('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
});
}, function(){
$('.animateme').html('<img src="Construct2/Images/Gnoll_Running_left.gif" />');
$('.animateme').animate({
left: '-=500',
}, 2200, function() {
$('.animateme').html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
});
});
});
</script>
的问题是,我想“#Homebutton”更改为红色关于通过Gnoll_Hit动画半途而废。所以我拼接了Hit动画,但没有做到。
我想我必须用回调来做这件事,因为在最后一个动画完成后,我希望它进入按钮链接。
是啊,我真的觉得你正在寻找一个“流量控制库”,也就是更好比jQuery的。你可以用animate()和setTimeout()完成这个目标,但最终这种动画风格需要比jquery提供的更彻底的时间线。 – BishopZ