我做嵌套動畫像以下序列:無法防止動畫隊列建立使用jquery
- 懸停在圖像1
- 顯示行1
- 隱藏線1
- 顯示行2
- 隱藏線2
- (等用於線路3 4 5)
我的小提琴:http://jsfiddle.net/z9Unk/119/
我只得到所需的行爲,如果我做控制時尚懸停。例如。如果我只徘徊一次,我會得到上面提到的行爲。
但是,如果我進/出多次徘徊快,我變得非常不一致的行爲。我在網上嘗試了各種建議,但無法使其工作。
我的期望是:即使我將鼠標懸停多次隨機,我應該得到相同的行爲,就好像「我將鼠標懸停只有一次,讓動畫完整的」我會得到。
請幫忙。我掙扎着。
HTML:
<div class="hover">
Hover Me
</div>
<div class="item1">
<div class="a">
text for a
</div>
<div class="b">
text for b
</div>
<div class="c">
text for c
</div>
<div class="d">
text for d
</div>
</div>
CSS:
.hover {
width: 100px;
height: 60px;
border: 1px solid red;
}
.item1 {
margin:25px;
width:600px;
height:400px;
border:10px solid green;
}
.a, .c {
clear: both;
float:left;
margin-top: 6%;
margin-left: 35px;
opacity:0.0;
font-size:30px;
}
.b, .d {
clear: both;
float:right;
margin-top: 6%;
margin-right: 25px;
opacity:0.0;
font-size:30px;
}
的jQuery:
a = $(".a");
b = $(".b");
c = $(".c");
d = $(".d");
$(".hover").hover(
function() {
a.animate({opacity:1.0}, 2000, function() {
a.animate({opacity:0.0},3000, function() {
b.animate({opacity:1.0},2000, function() {
b.animate({opacity:0.0}, 3000, function() {
c.animate({opacity:1.0}, 2000, function() {
c.animate({opacity:0.0}, 3000, function() {
d.animate({opacity:1.0},2000, function() {
d.animate({opacity:0.0}, 3000, function() {
}); }); }); }); }); }); });
});
},
function() {
a.opacity(0); //psuedcode
b.opacity(0);
c.opacity(0);
d.opacity(0);
a.stop(true, true);
b.stop(true, true);
c.stop(true, true);
d.stop(true, true);
}
);
u需要停止先前的動畫使用jQuery停止HTTP://api.jquery。com/stop/ – wilsonrufus