修改 Flipbook jquery 以加快加载速度

发布于 2024-11-19 09:29:37 字数 717 浏览 2 评论 0原文

我正在使用 Flipbook jquery 插件 和一个大的 png 图像序列。我给插件的创建者发了电子邮件,询问是否有任何方法可以创建某种“加载器”或允许它分块加载并在加载一定数量的图像后开始播放。他的回应如下:

这应该是可能的,我正在考虑这样做,但当时不需要。

在翻书代码中,shouldStartAnimation 函数通过递增计数器并根据总帧数检查该计数器来确定动画是否应开始。当所有帧都已加载后,计时器启动,翻转帧。可以更改此代码,以便计时器在加载一半帧或其他内容后启动。它还可以变得非常奇特,计算出每个帧加载需要多长时间,然后猜测在开始播放序列之前需要加载多少帧,以便在需要时加载所有帧。

不幸的是,我没有时间自己进行这些更改,但请随意根据您的需要修改此代码:)

https://gist.github.com/719686

不幸的是,我不知道足够的 javascript 来完成这项工作,而且我也不知道这对于这样做的人来说到底需要多少工作。我只是希望这里有人可能有一些更有用的信息或建议来帮助我解决这个问题(或者,显然,如果这对某人来说足够容易做到,那就太棒了)。

I am using the Flipbook jquery plugin with a large png image sequence. I emailed the creator of the plugin and asked if there's any way to create some sort of "loader" or allow it to load in chunks and start playing after a certain amount of images are loaded. He responded with the following:

This should be possible and I was thinking of doing this but it wasn't needed at the time.

In the flip book code the shouldStartAnimation function determines if the animation should start by incrementing a counter and checking that counter against the total number of frames. When all the frames have been loaded the timer starts which flips the frames. This code could be changed so the timer starts after half the frames were loaded or something. It could also get really fancy and figure out how long each frame is taking to load and then guess how many frames it needs to let load before it can start playing the sequence so all the frames are loaded by the time it needs them.

Unfortunately I don't have time to make these changes myself, but feel free to modify this code for your needs :)

https://gist.github.com/719686

Unfortunately I don't know enough javascript to get this done, and I don't know exactly how much work this would be for someone who did. I am just hoping someone here might have some more helpful info or advice to help me figure this out (or, obviously, if this is easy enough for someone to just do, that would be amazing).

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

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

发布评论

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

评论(1

话少情深 2024-11-26 09:29:37

添加一个默认选项,如下所示,确保在正确的位置有正确的“逗号”。

'loadbeforestart': 10, //start animation when 10 frames are loaded

并在以下函数中编辑变量,将变量“end”替换为“loadbeforestart”

function shouldStartAnimation(){
    //console.log('pre: '+imageName(i));
    preloadCount += step;
    if(preloadCount >= loadbeforestart){
        setTimeout(flipImage, holdTime);
    }
}

,我认为这应该可以解决问题*

Add one more option default, the following, make sure to have proper "comas" in right places.

'loadbeforestart': 10, //start animation when 10 frames are loaded

And edit a variable in the following function, replace variable "end" with "loadbeforestart"

function shouldStartAnimation(){
    //console.log('pre: '+imageName(i));
    preloadCount += step;
    if(preloadCount >= loadbeforestart){
        setTimeout(flipImage, holdTime);
    }
}

This should do the trick, I think*

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文