JQuery Cycle 插件 - 幻灯片之间的延迟间隔问题

发布于 2024-11-08 12:43:56 字数 362 浏览 4 评论 0原文

我正在使用 jQuery Cycle Plugin 作为图像滑块。我正在寻找的是这样的:

image1.jpg >>>淡出>>按住空白框一秒钟>>淡入 image2.jpg>>重复

如何控制下一个淡入淡出动画开始之前的延迟或 2 个幻灯片转换之间的间隔?

我的意思是,当第一张幻灯片图像完全淡出时,我需要它在第二张图像实际开始淡入动画之前暂停 1 或 2 秒。

** 当我使用寻呼机或下一个/上一个链接更改幻灯片时,我需要让它发挥作用。

我尝试过将sync:0设置为停止两张幻灯片之间的同时淡入淡出过渡,但这并不完全是我想要的。

任何建议将不胜感激,谢谢。

I'm using jQuery Cycle Plugin for an image slider. What I'm looking for is something like this:

image1.jpg >> fadeout >> hold on the blank frame for a second >> fadein image2.jpg >> repeat

How can I control the delay before the next fade animation starts, or the interval between 2 slide transitions?

I mean when the first slide image completely fades out, I need it to pause for 1 or 2 seconds before the second image actually begins its fadein animation.

** I need to get this to work during when I'm changing slides with the pager or next/prev links.

I've tried turning sync: 0 to stop simultaneous fading transition between 2 slides but not quite what I was looking for.

Any advice will be appreciated, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

段念尘 2024-11-15 12:43:56

您可以定义自定义过渡,淡出当前幻灯片,等待,然后淡入下一张幻灯片。

有关比下面更完整的示例,请参阅:http://jsfiddle.net/QGRv9/1/

$.fn.cycle.transitions.fadeOutWaitFadeIn = function($cont, $slides, opts) {
    opts.fxFn = function(curr, next, opts, after) {
        $(curr).fadeOut(opts.fadeSpeed, function() {
            $(next).delay(opts.delayBetweenFades).fadeIn(opts.fadeSpeed, function() {
                after();              
            });
        });
    };
};

$(function() {
    $('#slideshow').cycle({
        fx: 'fadeOutWaitFadeIn',
        fadeSpeed: 500,
        delayBetweenFades: 2000,
        //The timeout value includes the fade speed (twice) and delay between fades.
        //e.g. For a 3000 ms timeout, use 3000 + 500 * 2 + 2000 = 6000.
        timeout: 6000
    });
});

请注意,我在这里可能做错了什么。超时不必包含其他值。还有一个小问题:第一张幻灯片的显示时间为 6000 毫秒,而不是 3000 毫秒。

You can define a custom transition which fades out the current slide, waits, and then fades in the next slide.

For a more complete example than below, see: http://jsfiddle.net/QGRv9/1/

$.fn.cycle.transitions.fadeOutWaitFadeIn = function($cont, $slides, opts) {
    opts.fxFn = function(curr, next, opts, after) {
        $(curr).fadeOut(opts.fadeSpeed, function() {
            $(next).delay(opts.delayBetweenFades).fadeIn(opts.fadeSpeed, function() {
                after();              
            });
        });
    };
};

$(function() {
    $('#slideshow').cycle({
        fx: 'fadeOutWaitFadeIn',
        fadeSpeed: 500,
        delayBetweenFades: 2000,
        //The timeout value includes the fade speed (twice) and delay between fades.
        //e.g. For a 3000 ms timeout, use 3000 + 500 * 2 + 2000 = 6000.
        timeout: 6000
    });
});

Note that I'm probably doing something wrong here. The timeout shouldn't have to include the other values. There's also one small issue: The first slide gets shown for 6000ms instead of 3000ms.

情深如许 2024-11-15 12:43:56

一种方法是在每张图像后插入一张空白幻灯片。然后,您可以使用 timeoutFn 选项根据幻灯片是图像还是空白幻灯片提供不同的超时值。

以下是图像显示 5 秒、空白幻灯片显示 2 秒的示例:

http://jsfiddle.net/ 7jJe3/

<div id="slideshow">
    <img src="image1.jpg" />
    <span></span>
    <img src="image2.jpg" />
    <span></span>
    <img src="image3.jpg" />
    <span></span>
</div>

function timeoutfn(currSlideElement, nextSlideElement, options, forwardFlag) {
    var imgtime = 5000;
    var blanktime = 2000;
    if ($(currSlideElement).is('img'))
        return imgtime;
    return blanktime;
};

$(function() {
    $('#slideshow').cycle({
        fx: 'fade',
        speed: 400,
        timeoutFn: timeoutfn
    });
});

One way is to insert a blank slide after each image. You can then use the timeoutFn option to give a different timeout value depending on whether the slide is an image or a blank slide.

Here's an example where the images are displayed for 5 seconds and blank slides are displayed for 2 seconds:

http://jsfiddle.net/7jJe3/

<div id="slideshow">
    <img src="image1.jpg" />
    <span></span>
    <img src="image2.jpg" />
    <span></span>
    <img src="image3.jpg" />
    <span></span>
</div>

function timeoutfn(currSlideElement, nextSlideElement, options, forwardFlag) {
    var imgtime = 5000;
    var blanktime = 2000;
    if ($(currSlideElement).is('img'))
        return imgtime;
    return blanktime;
};

$(function() {
    $('#slideshow').cycle({
        fx: 'fade',
        speed: 400,
        timeoutFn: timeoutfn
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文