jQuery同位素队列随机播放/随机化动画 [英] jQuery Isotope queue shuffle/randomize animation

查看:73
本文介绍了jQuery同位素队列随机播放/随机化动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置 jQuery Isotope 随机播放方法,以对每个加载的DOM元素执行动画随机播放30秒内有人在页面上加载了插件.

I would like to set the jQuery Isotope shuffle method to to perform an animated shuffle of the loaded DOM elements every 30 seconds that someone is on the page with the plugin loaded.

我已经成功地将动画与.hover()事件相关联,但是当我使用setInterval().queue()时似乎无法启动它.我希望无论用户交互/输入如何都触发动画.

I have had success tying the animation to a .hover() event, but I cannot seem to get it to fire when I use setInterval() or .queue(). I want the animation to fire regardless of user interaction/input.

var iso_shuffle = function() {
    $('#isotope').isotope('shuffle');
}

setInterval(iso_shuffle(), 2500);

为什么前面的代码没有触发随机化,但是却触发了:

Why does the previous code not trigger the randomization, yet this does:

$('#isotope').hover(function() {
    iso_shuffle()
});

欢呼

推荐答案

iso_shuffle()立即调用该函数.该函数不返回任何内容.因此,您的setInterval实际上正在执行以下操作:

iso_shuffle() calls the function immediately. The function returns nothing. So your setInterval is actually doing the equivalent of:

setInterval(undefined, 2500);

您要将函数名称用作setInterval的回调:

You want to use the function name as the callback for setInterval:

setInterval(iso_shuffle, 2500);

这篇关于jQuery同位素队列随机播放/随机化动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆