From 87b3572ce594636ea57302cbe4f93c2d50ff39c0 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 26 Feb 2017 12:57:24 +0100 Subject: [PATCH] client/paging: fix endless scroll on android --- client/js/views/endless_page_view.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/client/js/views/endless_page_view.js b/client/js/views/endless_page_view.js index 93fb5200..ab406623 100644 --- a/client/js/views/endless_page_view.js +++ b/client/js/views/endless_page_view.js @@ -6,11 +6,15 @@ const views = require('../util/views.js'); const holderTemplate = views.getTemplate('endless-pager'); const pageTemplate = views.getTemplate('endless-pager-page'); -function isScrolledIntoView(el) { - const elemTop = el.getBoundingClientRect().top; - const elemBottom = el.getBoundingClientRect().bottom; - const isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight); - return isVisible; +function isScrolledIntoView(element) { + let top = 0; + do { + top += element.offsetTop || 0; + element = element.offsetParent; + } while(element); + return ( + (top >= window.scrollY) && + (top <= window.scrollY + window.innerHeight)); } class EndlessPageView { @@ -110,9 +114,6 @@ class EndlessPageView { if (this.totalRecords === null) { return; } - let scrollHeight = - document.documentElement.scrollHeight - - document.documentElement.clientHeight; if (this.minOffsetShown > 0 && isScrolledIntoView(this.topPageGuardNode)) {