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,23 +164,40 @@ onMounted(async () => { ...@@ -164,23 +164,40 @@ onMounted(async () => {
164 }, 500); 164 }, 500);
165 // TAG: 监听滚动到底部 165 // TAG: 监听滚动到底部
166 // 快捷访问组件高度动态调整 166 // 快捷访问组件高度动态调整
167 - window.onscroll = function () { 167 + // window.onscroll = function () {
168 - //变量scrollTop是滚动条滚动时,距离顶部的距离 168 + // //变量scrollTop是滚动条滚动时,距离顶部的距离
169 - const scrollTop = document.documentElement.scrollTop||document.body.scrollTop; 169 + // const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
170 - //变量windowHeight是可视区的高度 170 + // //变量windowHeight是可视区的高度
171 - const windowHeight = document.documentElement.clientHeight || document.body.clientHeight; 171 + // const windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
172 - //变量scrollHeight是滚动条的总高度 172 + // //变量scrollHeight是滚动条的总高度
173 - const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight; 173 + // const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
174 - //滚动条到底部的条件 174 + // //滚动条到底部的条件
175 - if(scrollTop + windowHeight === scrollHeight){ 175 + // if(scrollTop + windowHeight === scrollHeight){
176 - // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight); 176 + // // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
177 - customStyle.value.bottom = '35%' 177 + // customStyle.value.bottom = '35%'
178 - } else { 178 + // } else {
179 - customStyle.value.bottom = '8rem' 179 + // customStyle.value.bottom = '8rem'
180 - } 180 + // }
181 - } 181 + // }
182 }) 182 })
183 183
184 +// 快捷访问组件高度动态调整
185 +window.onscroll = function () {
186 + //变量scrollTop是滚动条滚动时,距离顶部的距离
187 + const scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
188 + //变量windowHeight是可视区的高度
189 + const windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
190 + //变量scrollHeight是滚动条的总高度
191 + const scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
192 + //滚动条到底部的条件
193 + if (parseInt(scrollTop + windowHeight) === scrollHeight){
194 + // console.warn("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
195 + customStyle.value.bottom = '35%'
196 + } else {
197 + customStyle.value.bottom = '8rem'
198 + }
199 +}
200 +
184 // 判断是否显示简介的展开图标 201 // 判断是否显示简介的展开图标
185 const hasToggle = ref(false); // 判断是否有展开文字,默认没有 202 const hasToggle = ref(false); // 判断是否有展开文字,默认没有
186 const isToggle = ref(true); // 判断展开状态,默认展开 203 const isToggle = ref(true); // 判断展开状态,默认展开
......