Fix loading related articles on small screens

Related articles are loaded when the user scrolls past
half the document height, which used to be calculated on
page load. This height, however, changes after all sections
are collapsed on small screens, thus never loading the
related articles for the page. Calculating the document height
just before showing related articles allows us to correctly
decide whether it's time to load the needed modules.

Bug: T121263
Change-Id: I1266894ab763cfb571b14f067086445fb6be1887
This commit is contained in:
Baha 2015-12-14 15:34:17 +05:00
parent ed338bbed5
commit a3d9b22a66

View file

@ -12,13 +12,14 @@
debouncedLoad = $.debounce( 100, function () {
loadRelatedArticles();
} ),
$window = $( window ),
$window = $( window );
function loadRelatedArticles() {
/**
* Threshold value to load related articles - after about half scroll
*/
scrollThreshold = ( $( document ).height() / 2 ) - $window.height();
var scrollThreshold = ( $( document ).height() / 2 ) - $window.height();
function loadRelatedArticles() {
if ( $window.scrollTop() > scrollThreshold ) {
$.when(
// Note we load dependencies here rather than ResourceLoader