Authored by zhangwenxue

fix(商品详情): 回退页面高度为窗口高度

当页面回退时,pageScrollHeight高度为0,此时使用app页面高度做fallback
export default {
deactivated() {
this.preVisibleEls = null;
},
methods: {
isVisible(offsetInfo, viewInfo, ratio = 0.5) {
return !((offsetInfo.offsetTop + offsetInfo.offsetHeight * (1 - ratio)) < viewInfo.top ||
... ... @@ -7,7 +10,22 @@ export default {
scrollEndHandler({y = this.$refs.pageScroll && this.$refs.pageScroll.$el.offsetTop} = {}) {
const scrollTop = Math.abs(y);
const pageScrollHeight = this.$refs.pageScroll.$el.offsetHeight;
let pageScrollHeight = this.$refs.pageScroll.$el.offsetHeight;
if (pageScrollHeight === 0) {
const app = document.querySelector('#app');
const header = document.querySelector('.layout-header');
const footer = document.querySelector('.footer');
pageScrollHeight = app && app.offsetHeight || window.innerHeight;
if (header) {
pageScrollHeight -= header.offsetHeight;
}
if (footer) {
pageScrollHeight -= footer.offsetHeight;
}
}
const viewInfo = {
top: scrollTop,
bottom: scrollTop + pageScrollHeight,
... ...