jenkins-bot has submitted this change and it was merged. Change subject: Upgrade isElementInViewport to be more exact ......................................................................
Upgrade isElementInViewport to be more exact Otherwise lazy loaded images stay without loading even when really visible. Bug: T126591 Change-Id: Idef5052000ac0448974066caa4df87af93951690 --- M resources/mobile.startup/util.js 1 file changed, 10 insertions(+), 4 deletions(-) Approvals: Jhernandez: Looks good to me, but someone else must approve Bmansurov: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/mobile.startup/util.js b/resources/mobile.startup/util.js index 2db21ba..b0c83e2 100644 --- a/resources/mobile.startup/util.js +++ b/resources/mobile.startup/util.js @@ -40,7 +40,8 @@ }, /** - * Check if at least half of the element's height and half of its width are in viewport + * Check if some of the element is in viewport + * FIXME: Remove in favor of core's mw.viewport once T129466 is fixed * * @method * @param {jQuery.Object} $el - element that's being tested @@ -56,9 +57,14 @@ elOffset = $el.offset(); return ( - ( windowScrollTop + windowHeight >= elOffset.top + elHeight / 2 ) && - ( windowScrollLeft + windowWidth >= elOffset.left + elWidth / 2 ) && - ( windowScrollTop <= elOffset.top + elHeight / 2 ) + // Bottom border must be below viewport's top + ( elOffset.top + elHeight >= windowScrollTop ) && + // Top border must be above viewport's bottom + ( elOffset.top <= windowScrollTop + windowHeight ) && + // Right border must be after viewport's left border + ( elOffset.left + elWidth >= windowScrollLeft ) && + // left border must be before viewport's right border + ( elOffset.left <= windowScrollLeft + windowWidth ) ); } }; -- To view, visit https://gerrit.wikimedia.org/r/275876 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idef5052000ac0448974066caa4df87af93951690 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jhernandez <jhernan...@wikimedia.org> Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org> Gerrit-Reviewer: Jhobs <jhob...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits