js获取滚动距离底部距离
滚动内容的高度-滚动容器的高度-设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离(获取元素到滚动列表顶部的距离)this.getToBottom= (this.getScrollHeight()-this.getClientHeight()-this.scrollTop)getScrollHeight(){return this.$refs.navConLis...
·
滚动内容的高度-滚动容器的高度-设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离(获取元素到滚动列表顶部的距离)
this.getToBottom= (this.getScrollHeight()-this.getClientHeight()-this.scrollTop)
getScrollHeight(){
return this.$refs.navConListRef.scrollHeight;
},
getClientHeight(){
var clientHeight = 0
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight)
} else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight)
}
return clientHeight
},
getScrollTop () {
this.scrollTop = this.$refs.navConListRef.scrollTop
console.log(this.scrollTop)
// this.$refs.navConListTrRef.style.transform = 'translateY(-'+(this.scrollTop)+ 'px)'
},
更多推荐
已为社区贡献1条内容
所有评论(0)