diff --git a/public/js/product/product-list-with-filter.js b/public/js/product/product-list-with-filter.js index 01eea29..097ba66 100644 --- a/public/js/product/product-list-with-filter.js +++ b/public/js/product/product-list-with-filter.js @@ -67,12 +67,14 @@ class ProductListWithFilter { /** * 滚动加载 */ - $(window).scroll(function() { - setTimeout(function() { + $(window).scroll(() => { + setTimeout(() => { let afterScroll = document.body.scrollTop; if (afterScroll - this.beforeScroll > 0) { - window.requestAnimationFrame(this.scrollHandler()); + window.requestAnimationFrame(() => { + this.scrollHandler(); + }); this.beforeScroll = afterScroll; } else { return false; @@ -341,8 +343,9 @@ class ProductListWithFilter { * 当scroll到1/2$goodsContainer高度后继续请求下一页数据 */ scrollHandler() { - if (this.view.allGoodsTabPage.hasClass('active') && - $(window).scrollTop() > this.view.goodsContainer.height() * 0.6) { + let goodsContainerHeight = this.view.goodsContainer.height(); + + if ($(window).scrollTop() > goodsContainerHeight * 0.6) { this.isScrollLoad = true; this.getGoodsList(); }