今天给轮播图加淡入淡出动画,死活不生效…查了半天发现是用的 fadeIn() 但父容器 display: none 了,jQuery 动画压根不触发!
后来改成 show().fadeIn(300) 才行,或者直接用 css opacity + transition 更稳…
顺手翻了下老代码,居然还有人写 $(el).animate({opacity: 0}, 200).remove() 却忘了加 queue: false,结果动画卡住不动,后面一堆 callback 全等在那儿…
现在改用 stop(true, true).fadeOut(200) 少踩好多坑…
后来改成 show().fadeIn(300) 才行,或者直接用 css opacity + transition 更稳…
顺手翻了下老代码,居然还有人写 $(el).animate({opacity: 0}, 200).remove() 却忘了加 queue: false,结果动画卡住不动,后面一堆 callback 全等在那儿…
现在改用 stop(true, true).fadeOut(200) 少踩好多坑…
$('.banner').stop(true, true).fadeOut(200, function() {
$(this).css('display', 'none');
});
登录/注册