GIF slider in flexslider, how to begin the gif only when on slider(flexslider 中的 GIF 滑块,如何仅在滑块上开始 gif)
问题描述
现在我有一个带有四张幻灯片的 flexslider.第三个滑块是 gif 而不是像其他滑块一样的 jpg.我遇到的问题是,这第三个 gif 滑块显然在到达页面时立即启动,而不是在您实际到达该滑块时启动.当一个人点击前两个滑块时,gif 就快完成了.
Right now I have a flexslider with four slides. The third slider is a gif rather than a jpg like the others. The issue I am having is that this third gif slider apparently starts immediately when the page is reached as opposed to when you actually get to that slider. By the time one clicks through the first two sliders, the gif is just about finished.
任何人都知道我将如何开始一个 GIF,只有当一个人达到那个滑块?
Anyone have any idea as to how I would begin a GIF only when one reaches that slider?
推荐答案
经过一小时的测试,我终于找到了解决方案,在你的声明代码中添加before函数,并更改<将下一个
清空并返回到原来的 img
的 code>srcsrc
做这项工作,如下所示:
I finally found the solution for you after one hour of test, add the before
function to your declaration code, and change the src
of next img
to empty and back to the original src
do the work, like bellow :
JS:
此代码将在显示之前初始化 gif.
this code will init the gif just before the display.
$('.flexslider').flexslider({
animation: "slide",
before: function(slider){
var src = $(slider).find('.flex-active-slide').next().find('img').attr('src');
$(slider).find('.flex-active-slide').next().find('img').attr('src','').attr('src',src);
}
});
它非常适合我.
参见 JS Fiddle(你可以注意到 gif 中的计数器总是从 10 开始,没有 before
功能你会发现计数器已经开始),希望有所帮助.
See JS Fiddle (you can notice that the counter in gif always start by 10, without before
function you find that the counter is already start), hope that help.
这篇关于flexslider 中的 GIF 滑块,如何仅在滑块上开始 gif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:flexslider 中的 GIF 滑块,如何仅在滑块上开始 gif
基础教程推荐
- 响应更改 div 大小保持纵横比 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 动态更新多个选择框 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01