想要将自动播放设置添加到响应式图像库
Want to add Autoplay setting to Responsive Image Gallery.
我已将此图片库 http://tympanus.net/codrops/2011/09/20/responsive-image-gallery/添加到我正在处理的站点。完美运行,唯一的问题是没有自动播放幻灯片的选项。
http://www.debellephotography.com/debelleslide/
任何帮助将不胜感激!
我在这里和那里拼凑起来,想出一种方法来做到这一点,谢谢你的帮助。
var t;
var timer_is_on=0;
function timedCount()
{
$('.rg-image-nav-next').click()
t=setTimeout("timedCount()",1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount(1000);
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
timeCount 函数每 1 秒激活下一个图像。doTimer 功能可防止多次激活计时器。stopCount 函数允许暂停幻灯片放映。
然后,我添加了两个按钮来暂停和播放:
<div class="playbutton"><a href="javascript:doTimer();"><img src="images/play.png" width="24" height="24" alt="Play"></a></div>
<div class="pausebutton"><a href="javascript:stopCount();"><img src="images/pause.png" width="24" height="24" alt="Pause"></a></div>
您可以在此处看到它的工作原理:自动播放示例
您希望创建一个新按钮,用于触发 setInterval 函数循环浏览幻灯片。它看起来像这样:
<button onclick="play()">slideshow</button>
function play() {
setInterval(function() {
// Do the code that triggers next image
}, 1000);
}
数字 1000 是运行函数之间的毫秒数。
试试这个
var current=1;
function autoAdv()
{
if(current==-1) return false;
$('.es-carousel a').eq(current%$('.es-carousel a').length).trigger('click',[true]); // [true] will be passed as the contentScroll parameter of the click function
current++;
$('.rg-image-nav-prev').eq(current%$('.rg-image-nav-prev').length).trigger('click',[true]); // [true] will be passed as the contentScroll parameter of the click function
current++;
}
// The number of seconds that the slider will auto-advance in:
var changeEvery = 10;
var itvl = setInterval(function(){autoAdv()},changeEvery*1000);
相关文章:
- 具有javascript document.write的响应图像
- 网格状、多响应图像
- 响应图像tinymce图像链接
- jQuery Mobile Listview中的响应图像
- 使用getJSON填充动画响应图像网格
- 响应图像(通过管道和response.end())会导致奇怪的行为
- 创建响应图像的最简单方法是什么
- 在引导列中垂直居中响应图像
- 引导程序:面板中的响应图像
- 基于JQuery的全宽响应图像滑块已损坏
- 像元srcset响应图像翻转
- 具有翻转/图像交换功能的响应图像地图位于潜水器外部
- 检测宽度并使用响应图像
- 简单的响应图像方法
- 固定位置的响应图像周围的内容
- 响应图像映射与坐标
- 我如何使一个响应图像地图,其中图像和热点自动调整大小与窗口
- 覆盖响应图像
- 响应图像滑块居中图像
- 如何在不影响图像大小的情况下对响应图像进行中心缩放