client/paging: fix endless scroll on android

This commit is contained in:
rr- 2017-02-26 12:57:24 +01:00
parent 5467ca6b7e
commit 87b3572ce5
1 changed files with 9 additions and 8 deletions

View File

@ -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)) {