From 7e05b6c1dfa8bb70df797ec8bb5a040875c8c8b8 Mon Sep 17 00:00:00 2001 From: 郭成尧 <chengyao.guo@yoho.cn> Date: Fri, 28 Jul 2017 11:02:06 +0800 Subject: [PATCH] Scroll --- public/js/product/product-list-with-filter.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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(); } -- libgit2 0.24.0