我想在我的网站上实现这样的东西:
当用户滚动到文章末尾时应该出现 slider
是否有一个 jQuery 插件可以处理这个问题? jQuery Waypoints看起来很有希望,但我希望有人有更具体的解决方案。
最佳答案
不需要插件:
$(window).scroll(function() {
var windowHeight = $(window).height(),
documentHeight = $(document).height(),
scroll = $(window).scrollTop();<p></p>
<p>if (windowHeight + scroll + 200 > documentHeight ) {
// show the link bar
}
});</p>
当您距离底部 200 像素以内时,将显示链接栏。 windowHeight
将保存屏幕可见部分的高度,documentHeight
将保存页面的总高度,包括您可以看到和看不到的内容, >scroll
将保存您滚动到文档顶部的距离(从 0 开始)。
希望这有帮助:)
关于jquery - 实现 nytimes 风格 "end of article suggestion slider",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5111701/