jQuery 循环 +最小超时

发布于 2024-12-10 02:14:22 字数 917 浏览 3 评论 0原文

我在 jQuery 循环插件及其超时方面遇到了一个小问题。

我正在使用 scrollLeft 效果,并希望让它始终保持滚动(类似于新闻收报机,如果您知道我的意思的话)。现在使用 timeout: 0 将不起作用,因为它会完全禁用自动滚动。

所以我想到使用 timeout: 10 (有一个几乎不明显的超时),但这也不起作用,因为无论我将超时设置得多低,超时似乎总是大约一秒(即使使用超时:1)。

再次使它更清楚一点:

将超时增加到 timeout: 10000 可以达到预期的效果并暂停滑动 10 秒,但将其减少到 timeout: 1 看起来就像我使用 timeout: 1000 一样,

我不确定问题出在哪里,因为我在 Google 上到处寻找最小超时,但找不到任何说明超时最小值为 1000

我使用的脚本非常简单,所以我认为那里应该没有错误,但只是为了让您也可以检查我发布它:

    $('#demo').cycle({
        slideExpr: 'p',
        fx: 'scrollLeft',
        next: '.next', 
        speedIn: 5000,
        speedOut: 5000,
        fastOnEvent: 1000,
        containerResize: 0,
        pause: 1,
        timeout: 10
    });

我希望我能够解释我的问题很好:)

问候!

ps 我不想使用某种 newsticker 插件,但真的很想用循环创建这种效果。

I am having a small problem with the jQuery cycle plugin and its timeout.

I am using the scrollLeft effect and would like to get it to always keep scrolling (similar to a news ticker if you know what I mean). Now using timeout: 0 will not work, because it would disable the auto scolling at all.

So I thought of using timeout: 10 (to have a almost non noticeable timeout), but this doesnt work too, because no matter how low I set the timeout, the timeout always seems to be about a second (even when using timeout: 1).

Again to make it a bit more clear:

Increasing the timeout to timeout: 10000 has the desired effect and pauses the sliding for 10 seconds, but decreasing it to timeout: 1 looks just like as if I used timeout: 1000

I am not sure where the problem is, because I was looking all around Google for minimum timeout, but couldnt find anything that said the timeout minimum is 1000

The script I am using is very simple, so I think there should be no errors there, but just so that you can check that too I post it:

    $('#demo').cycle({
        slideExpr: 'p',
        fx: 'scrollLeft',
        next: '.next', 
        speedIn: 5000,
        speedOut: 5000,
        fastOnEvent: 1000,
        containerResize: 0,
        pause: 1,
        timeout: 10
    });

I hope I was able to explain my question well enough :)

Regards!

p.s. I dont want to use some sort of newsticker plugin, but would really like to create that effect with cycle.

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

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

发布评论

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

评论(3

猥琐帝 2024-12-17 02:14:22

如果您需要真正连续的滚动,可以使用 easeIneasyOut 选项。试试这个:

$('#demo').cycle({
   fx: 'scrollHorz',
   continuous: 1,
   easeIn: 'linear',
   easeOut: 'linear'
});

If you need a really continuous scroll, you can use the easeIn and easyOut options. Try this:

$('#demo').cycle({
   fx: 'scrollHorz',
   continuous: 1,
   easeIn: 'linear',
   easeOut: 'linear'
});
梦醒时光 2024-12-17 02:14:22

jQuery Cycle 有一个名为 连续 的选项,这是该插件能够实现的最接近的选项到传统的新闻行情。尝试以下操作:

$('#demo').cycle({ 
    fx: 'scrollLeft', 
    continuous: 1
});

我希望这会有所帮助!

There is an option for jQuery Cycle called continuous which is the closest the plugin is able to come to a traditional news-ticker. Try the following:

$('#demo').cycle({ 
    fx: 'scrollLeft', 
    continuous: 1
});

I hope this helps!

小耗子 2024-12-17 02:14:22

编辑:忽略这个答案,因为它需要更改代码。使用上面回答的连续选项。

在 buildOptions() 函数中找到以下代码

var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
while((opts.timeout - opts.speed) < buffer) // sanitize timeout
    opts.timeout += opts.speed;*/

并注释 while 循环

var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
/*while((opts.timeout - opts.speed) < buffer) // sanitize timeout
    opts.timeout += opts.speed;*/

Edit: Ignore this answer since it requires code change. Use continuous option as answered above.

In the buildOptions() function find the following code

var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
while((opts.timeout - opts.speed) < buffer) // sanitize timeout
    opts.timeout += opts.speed;*/

and comment the while loop

var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
/*while((opts.timeout - opts.speed) < buffer) // sanitize timeout
    opts.timeout += opts.speed;*/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文