简体   繁体   English

jQuery旋转器跳跃而不是从一个渐变到另一个

[英]jQuery rotator jumps instead of fading from one to the other

I tried to code a simple jQuery rotator to display changing HTML content in a widget. 我尝试编写一个简单的jQuery旋转器来显示窗口小部件中不断变化的HTML内容。

The widget itself works, and each div fades in and out, but they seem to overlap, resulting in both divs being shown for a split second. 小部件本身工作,每个div淡入淡出,但它们似乎重叠,导致两个div显示为瞬间。

How can I make it so that the visible div fades out, and after it's displayed as none, the other div starts to fade in? 我怎样才能使可见的div淡出,并且在显示为none之后,另一个div开始淡入?

function fadeNext() {
    $('#patient-stories .patient-story-single').first().fadeOut('slow').appendTo($('#patient-stories .inner'));
    $('#patient-stories .patient-story-single').first().fadeIn('slow');
}

http://jsfiddle.net/9f2bh164/ http://jsfiddle.net/9f2bh164/

UPDATE: 更新:

I've managed to get a bit closer, in that each div is fading out before the next one fades in, but it's not looping ie. 我已经设法更接近了,因为每个div在下一个淡入之前逐渐消失,但它不是循环的,即。 going back to the start when all divs have been shown. 当所有div都被显示时,回到开始。

http://jsfiddle.net/9f2bh164/2/ http://jsfiddle.net/9f2bh164/2/

SOLVED: 解决了:

http://jsfiddle.net/9f2bh164/3/ http://jsfiddle.net/9f2bh164/3/

Place the successive animations inside the previous one's callback to ensure they follow order. 将连续动画放在前一个回调中,以确保它们遵循顺序。

 function fadeNext() { $('#div1').fadeOut('slow', function() { $('#div2').fadeIn('slow'); }); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM