鼠标滚轮/滚动scroll

当 clientHeight + scrollTop >= scrollHeight 时,表明已经抵达内容的底部了,可以加载更多内容。

scrollHeight:可以通过 document.documentElement.scrollHeight 、document.body.scrollHeight 获取;
clientHeight:可以通过window.innerHeight 、 document.documentElement.clientHeight 获取;
scrollTop:可以通过window.pageYOffset 、 document.documentElement.scrollTop 获取;

Window innerWidth 和 innerHeight 属性 innerheight 返回窗口的文档显示区的高度。
//滚动条
鼠标滚轮/滚动scroll(window).height();//当前窗口的高度
var scrollTop = 鼠标滚轮/滚动scroll(document).height(); //当前文档的高度
console.log(scrollTop, windowHeight, docHeight);
// 触底公式:(滚动条滚动的高度 + 可视窗口的高度 = 文档的高度) 这个是基本的公式
if (scrollTop + windowHeight >= docHeight) {
console.log(“===加载更多数据===”);
}
});
//鼠标滚轮
window.addEventListener( wheel ,function(e){
var scrooTop = document.body.scrollTop||document.documentElement.scrollTop
// console.log(scrooTop)
var evt = e||window.event;
// evt.preventDefault()
if(evt.deltaY > 0){
if(scrooTop>=鼠标滚轮/滚动scroll(“.pop-pc”).removeClass(“hide”)
鼠标滚轮/滚动scroll(document).height(); == document.documentElement.scrollHeight; // 文档内容的实际高度
鼠标滚轮/滚动scroll(window).height(); == document.documentElement.clientHeight; // 可视窗口高度

window.onload=function(){
var a = 鼠标滚轮/滚动scroll(“#div”).innerWidth(),//innerWidth()返回元素的宽高 + padding
c = 鼠标滚轮/滚动scroll(“#div”).outerWidth(true);//outerWidth(true)返回元素宽高 + padding + border + margin
console.log(a,b,c,d);
}

获取浏览器显示区域(可视区域)的高度 :
鼠标滚轮/滚动scroll(window).width();
获取页面的文档高度
鼠标滚轮/滚动scroll(document).width();
浏览器当前窗口文档body的高度:
鼠标滚轮/滚动scroll(document.body).width();
获取滚动条到顶部的垂直高度 (即网页被卷上去的高度)
鼠标滚轮/滚动scroll(document).scrollLeft();
获取或设置元素的宽度:
鼠标滚轮/滚动scroll(obj).height();
某个元素的上边界到body最顶部的距离:obj.offset().top;(在元素的包含元素不含滚动条的情况下)
某个元素的左边界到body最左边的距离:obj.offset().left;(在元素的包含元素不含滚动条的情况下)
返回当前元素的上边界到它的包含元素的上边界的偏移量:obj.offset().top(在元素的包含元素含滚动条的情况下)
返回当前元素的左边界到它的包含元素的左边界的偏移量:obj.offset().left(在元素的包含元素含滚动条的情况下)

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容