0
演示http://www.bootply.com/gyEJYEzFeijQuery的動畫缺陷
顯然,動畫()非異步使他們不能在同一時間觸發的,但我不知道爲什麼當鼠標離開是有重疊的問題,在底排。我嘗試過渡與CSS,現在與動畫()仍然無法完善動畫。代碼
$('.hoverExpand').mouseenter(function() {
var $this = $(this);
var getIndexOfTarget = $this.closest('.product-panel').index();
if(getIndexOfTarget % 2 == 0){ //check target if is even
$('.product-panel').filter(function(i) {
return i > 2 && i % 2 == 1
}).animate({'margin-top':"-=100px",
"transition":"all 0.2s linear"
});
}else{
$('.product-panel').filter(function(i) {
return i > 1 && i % 2 == 0;
}).animate({'margin-top':"-=100px",
"transition":"all 0.2s linear"
});
}
if (!$this.hasClass('on')) {
$this.addClass('on');
$this.find('.productsThumbWrap').stop(true, true).animate({
"margin-top": "200px"
}, "fast",function(){
});
$this.find('.productsThumbWrap img').stop(true, true).css({
opacity: 1,
'transition': 'opacity 0.45s ease 0.15s'
});
}
});
'transition'屬性不可動畫。將它設置在你的CSS中,或者在鏈中的某處使用'.css({transition:「all 0.2s linear」})「。 – 2014-10-02 09:30:38