我想使这项工作,并可中断。应该有1秒的淡入淡出,1秒的淡出以及3秒的延迟,但是在3秒或1秒的淡入/淡出期间,可能会发生另一个应该发生的动作 - 停止先前的动作并且从不完成动作。 例如,在3秒显示图像期间,用户想要进入下一个/下一个/下一个/下一个,因此立即停止动画并转到下一个/下一个/下一个/下一个(多用户点击)这个。外部调用:SlideShow(1);其中,或幻灯片(-1);,等等jQuery淡入/淡出和延迟,取消以前的动画
function SlideShow(action) {
slideCount = (slideCount+action) % totalSlides;
slides.eq(slideCount).fadeIn(fadeInAmount);
// add 3 second delay/SetTimeout/etc here
// how should setTimeout be involved here so that it, and the fadein/fadeout are stoppable (without ever continuing)
slides.eq(slideCount).fadeOut(fadeOutAmount,function() {
slideCount = (slideCount+increment) % totalSlides;
SlideShow(0);
});
}
这与1秒淡入,3S延迟,1S淡出
slides.eq(slideCount).fadeIn(fadeInAmount).delay(fadeDelay).addClass('jqImage').fadeOut(fadeOutAmount,function() {
slideCount = (slideCount+increment) % totalSlides;
SlideShow(0);
});
这里起始点一个非工作的尝试使用的setTimeout:
function timerStop() {
if (runningTimer) {
clearTimeout(runningTimer);
runningTimer = 0;
}
}
var runningTimer;
function SlideShow(action) {
// $('body').stop(); slides.eq(slideCount).dequeue(); slides.eq(slideCount).stop();
slideCount=(slideCount+action) % totalSlides;
$('#slideControls').html(
(slideCount+1) + "/" + totalSlides
+ "<br>" + "Delay: " + fadeDelay/1000
+ "<br>" + "Skip: " + increment
);
$('#slideStatusbar').html(slides.eq(slideCount).find('img').attr('src').replace(/^.*[\\\/]/, '')); // Filename only
//slides.eq(slideCount).fadeIn(fadeInAmount).delay(fadeDelay).addClass('jqImage').fadeOut(fadeOutAmount,function() {
// slideCount < totalSlides-1 ? slideCount+=increment : slideCount=0;
// slideCount = (slideCount+increment) % totalSlides;
// SlideShow(0);
// slides.eq(slideCount).addClass('jqImage');
slides.eq(slideCount).fadeIn(fadeInAmount);
runningTimer=setTimeout(function(){
slides.eq(slideCount).fadeOut(fadeOutAmount,function() {
slideCount = (slideCount + increment) % totalSlides; //slideCount = (slideCount + (action ? action : increment)) % totalSlides;
SlideShow(0);
});
}, 1000);
}
“增量”是一个全局变量,设置为50,50个图像被自动跳过无需用户交互,但如果用户按下下一首/上,放下一切,做到这一点下一首/上,并恢复50增量在用户的下一个/上一个图像淡入之后,停留延迟,淡出。 – Roberto
任何人都可以帮忙吗? – Roberto
仍然在为此奋斗 – Roberto