【发布时间】:2016-01-03 23:17:14
【问题描述】:
我有一个网页,其中包含使用 javascript video 嵌入的文本和视频。我可以使用哪些 javascript/jquery 代码以设定的速度向下滚动页面、停止滚动、播放视频,然后继续滚动直到页面底部重新启动?
编辑: 我试过http://www.jquerybyexample.net/2013/05/jquery-scroll-page-automatically-by-few-pixels-after-every-few-seconds.html和http://jdsharp.us/jQuery/plugins/AutoScroll/和http://jsfiddle.net/NaP8D/11/。
//run instantly and then goes after (setTimeout interval)
$("html, body").animate({ scrollTop: $(document).height() }, 4000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 4000);
},4000);
setInterval(function(){
// 4000 - it will take 4 secound in total from the top of the page to the bottom
$("html, body").animate({ scrollTop: $(document).height() }, 4000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 4000);
},4000);
},8000);
我无法让代码暂停其中任何一个。
【问题讨论】:
-
编辑了帖子并添加了我尝试过的内容。
-
您的代码中没有任何地方等待视频播放/等待视频停止播放。这就是你遇到的问题吗?
-
该代码来自 jsfiddle。但是,是的,该代码有效,暂停滚动并使其等待是问题所在。
-
好的,给我几分钟时间整理一下代码。
标签: javascript jquery scroll html5-video autoscroll