判断是否有滚动到底部

5年以前  |  阅读数:362 次  |  编程语言:JavaScript 

如果页的底部可见, 则返回true, 否则为false

使用scrollYscrollHeightclientHeight来确定页面底部是否可见。

const bottomVisible = () =>
document.documentElement.clientHeight + window.scrollY >= document.documentElement.scrollHeight || document.documentElement.clientHeight;
// bottomVisible() -> true

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8