mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-11-24 00:05:50 +00:00
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:
parent
ed338bbed5
commit
a3d9b22a66
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue