循环滚动网站

时间:2015-10-22 00:18:03

标签: jquery html css scroll infinite-loop

我想创建一个网站,其中包含Unfold website的循环滚动功能。

一旦你一直向下滚动到底部,网站就会循环回到顶部,但它不会跳到顶部,它会无缝地完成,你甚至不会再知道你的位置。它还允许用户向上滚动并执行相同的操作。

我知道这个问题已经被问及“回答”here但是它确实不是我想要的。上一篇文章的答案很不错,但他们的解决方案并没有真正模拟展开无缝循环滚动。

我正在寻找一种解决方案,可以在端到端之间平滑地滚动和转换,反之亦然。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

请尝试使用此代码

if (document.documentElement.clientHeight + $(window).scrollTop() >= $(document).height()) {
    $(document).scrollTop(0)
} else if ($(window).scrollTop() < 1) {
    $(document).scrollTop($(document).height())
}