三个值(滚动视窗高度 + 当前已滚距离 >= 滚动内容总高度)
1.获取滚动视窗高度:$(window).height();(如果滚动区域不是整个页面,使用$('slector').height())
2.当前已滚距离:$(this).scrollTop();
3.获取滚动内容总高度:$(this).get(0).scrollHeight;
$('#members-scroll').mousewheel(function (e) {
var scrollTop = $(this).scrollTop();
var clientHeight = $(this).height();
var scrollHeight = $(this)[0].scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) {
//触发操作
}
}
vue中的滚动
methods: {
handleScroll(e) {
let scrollTop = $(e.target).scrollTop();
let clientHeight = $(e.target).height();
let scrollHeight = $(e.target)[0].scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) {
}
}
}
mounted() {
window.addEventListener('scroll', this.handleScroll, true);
}