jquery spritefy 暂停和重新启动
我正在使用这个插件: http://www.spritely.net/ 谁能告诉我为什么变量 $sprite 不重新执行?
function animate_header() {
var $sprite = $('#header')
.sprite({
fps: 30,
no_of_frames: 4,
// the following are optional: new in version 0.6...
start_at_frame: 1,
rewind: false,
on_last_frame: function(obj) {
// you could stop the sprite here with, e.g.
obj.spStop();
}
})
.active();
}
var init = setInterval("animate_header()", 1000);
我也尝试过这个:
function animate_header() {
$('#header')
.sprite({
fps: 30,
no_of_frames: 4,
// the following are optional: new in version 0.6...
start_at_frame: 1,
rewind: false,
on_last_frame: function(obj) {
// you could stop the sprite here with, e.g.
obj.spStop();
}
})
.active();
}
var init = setInterval("animate_header()", 1000);
函数本身每秒执行一次。但精灵却没有。
I'm useing this plugin: http://www.spritely.net/
Can anyone tell me why the variable $sprite doesn't re-execute?
function animate_header() {
var $sprite = $('#header')
.sprite({
fps: 30,
no_of_frames: 4,
// the following are optional: new in version 0.6...
start_at_frame: 1,
rewind: false,
on_last_frame: function(obj) {
// you could stop the sprite here with, e.g.
obj.spStop();
}
})
.active();
}
var init = setInterval("animate_header()", 1000);
I also tried this:
function animate_header() {
$('#header')
.sprite({
fps: 30,
no_of_frames: 4,
// the following are optional: new in version 0.6...
start_at_frame: 1,
rewind: false,
on_last_frame: function(obj) {
// you could stop the sprite here with, e.g.
obj.spStop();
}
})
.active();
}
var init = setInterval("animate_header()", 1000);
The function itself executes every second. But the sprite doesn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这对我有用。我首先设置选项,然后使用 spStart 函数循环它。
This is what worked for me. I set the options first, then I looped it with the spStart function.
对于其他可能偶然发现这一点的人,请使用
动画似乎在以其他方式运行几次后中断,但 destroy 修复了它:)
For anyone else that might happen to stumble on this, use
The animation seems to break after running a few times every other way, but destroy fixes it :)
尝试在代码末尾将
.active();
替换为.spStart();
。看起来像在最后一帧调用的 obj.spStop() 只会杀死动画,并且需要一个跳跃启动才能使其继续...
为我工作:)
try replacing
.active();
with.spStart();
at the end of your code.Looks like
obj.spStop()
that is called on last frame just kills animation dead and it needs a jump start to get it going...Worked for me :)
我最终这样做了。哪个如我所愿。
不过还是感谢您的回复。
I ended up doing this. Wich worked as I wanted.
Thanks for any replies though.