我正在尝试找出是否有像fullpage.js一样的滚动页面的解决方案。一页一页地滚动网站,上下滚动。
这与fullpage.js不同,因为它将页面滑动到不同的div,但我需要它在单个div中移动。
下面是我尝试过的代码:
<div> a very long text here..... </div>
Window.onscroll = function() {test()};
Function test(){ window.scrollby(0, 300) };上面的代码只是向下滚动,它不会停止。它会一直向下滚动,直到页面底部。
那么,怎么做呢?
发布于 2016-05-18 12:39:30
你需要一些东西来停止无限循环,试试这个...
<div> a very long text here..... </div>
Window.onscroll = function() {test()};
var isAutoScroll = false;
Function test(){
if(!isAutoScroll ){
isAutoScroll = true;//Next time will not scroll
window.scrollby(0, 300) };
}
else
{
isAutoScroll = false;
return;
}https://stackoverflow.com/questions/37290238
复制相似问题