hookehuyr

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

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-21 09:35:14 3 * @Date: 2022-05-21 09:35:14
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-24 14:29:32 5 + * @LastEditTime: 2022-06-24 14:35:03
6 * @FilePath: /tswj/src/views/client/bookDetail.vue 6 * @FilePath: /tswj/src/views/client/bookDetail.vue
7 * @Description: 7 * @Description:
8 --> 8 -->
...@@ -164,7 +164,25 @@ onMounted(async () => { ...@@ -164,7 +164,25 @@ onMounted(async () => {
164 }, 500); 164 }, 500);
165 // TAG: 监听滚动到底部 165 // TAG: 监听滚动到底部
166 // 快捷访问组件高度动态调整 166 // 快捷访问组件高度动态调整
167 - window.onscroll = function () { 167 + // window.onscroll = function () {
168 + // //变量scrollTop是滚动条滚动时,距离顶部的距离
169 + // const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
170 + // //变量windowHeight是可视区的高度
171 + // const windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
172 + // //变量scrollHeight是滚动条的总高度
173 + // const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
174 + // //滚动条到底部的条件
175 + // if(scrollTop + windowHeight === scrollHeight){
176 + // // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
177 + // customStyle.value.bottom = '35%'
178 + // } else {
179 + // customStyle.value.bottom = '8rem'
180 + // }
181 + // }
182 +})
183 +
184 +// 快捷访问组件高度动态调整
185 +window.onscroll = function () {
168 //变量scrollTop是滚动条滚动时,距离顶部的距离 186 //变量scrollTop是滚动条滚动时,距离顶部的距离
169 const scrollTop = document.documentElement.scrollTop||document.body.scrollTop; 187 const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
170 //变量windowHeight是可视区的高度 188 //变量windowHeight是可视区的高度
...@@ -172,14 +190,13 @@ onMounted(async () => { ...@@ -172,14 +190,13 @@ onMounted(async () => {
172 //变量scrollHeight是滚动条的总高度 190 //变量scrollHeight是滚动条的总高度
173 const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight; 191 const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
174 //滚动条到底部的条件 192 //滚动条到底部的条件
175 - if(scrollTop + windowHeight === scrollHeight){ 193 + if (parseInt(scrollTop + windowHeight) === scrollHeight){
176 // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight); 194 // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
177 customStyle.value.bottom = '35%' 195 customStyle.value.bottom = '35%'
178 } else { 196 } else {
179 customStyle.value.bottom = '8rem' 197 customStyle.value.bottom = '8rem'
180 } 198 }
181 - } 199 +}
182 -})
183 200
184 // 判断是否显示简介的展开图标 201 // 判断是否显示简介的展开图标
185 const hasToggle = ref(false); // 判断是否有展开文字,默认没有 202 const hasToggle = ref(false); // 判断是否有展开文字,默认没有
......