hookehuyr

fix 滚动高度取整,不然不一样

......@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-21 09:35:14
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-24 14:29:32
* @LastEditTime: 2022-06-24 14:35:03
* @FilePath: /tswj/src/views/client/bookDetail.vue
* @Description:
-->
......@@ -164,7 +164,25 @@ onMounted(async () => {
}, 500);
// TAG: 监听滚动到底部
// 快捷访问组件高度动态调整
window.onscroll = function () {
// window.onscroll = function () {
// //变量scrollTop是滚动条滚动时,距离顶部的距离
// const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
// //变量windowHeight是可视区的高度
// const windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
// //变量scrollHeight是滚动条的总高度
// const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
// //滚动条到底部的条件
// if(scrollTop + windowHeight === scrollHeight){
// // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
// customStyle.value.bottom = '35%'
// } else {
// customStyle.value.bottom = '8rem'
// }
// }
})
// 快捷访问组件高度动态调整
window.onscroll = function () {
//变量scrollTop是滚动条滚动时,距离顶部的距离
const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
//变量windowHeight是可视区的高度
......@@ -172,14 +190,13 @@ onMounted(async () => {
//变量scrollHeight是滚动条的总高度
const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
//滚动条到底部的条件
if(scrollTop + windowHeight === scrollHeight){
if (parseInt(scrollTop + windowHeight) === scrollHeight){
// console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
customStyle.value.bottom = '35%'
} else {
customStyle.value.bottom = '8rem'
}
}
})
}
// 判断是否显示简介的展开图标
const hasToggle = ref(false); // 判断是否有展开文字,默认没有
......