jenkins-bot has submitted this change and it was merged. Change subject: Restore anchor position ......................................................................
Restore anchor position Browsers scroll to the anchor position before everything on the page has been loaded. We want to wait until the items in DOM are loaded and then scroll to the anchor position. Bug: T91882 Change-Id: I9ca5272a96055c14713949bfc77a4a5f776c599f --- M javascripts/Page.js 1 file changed, 18 insertions(+), 1 deletion(-) Approvals: Phuedx: Looks good to me, approved jenkins-bot: Verified diff --git a/javascripts/Page.js b/javascripts/Page.js index 4f81d91..ab3ed2e 100644 --- a/javascripts/Page.js +++ b/javascripts/Page.js @@ -27,6 +27,7 @@ * @cfg {Array} defaults.sections Array of {Section} objects. * @cfg {Boolean} defaults.isMainPage Whether the page is the Main Page. * @cfg {Boolean} defaults.userCanUpload Whether the current user can upload. + * @cfg {String} defaults.hash Window location hash. */ defaults: { id: 0, @@ -38,7 +39,8 @@ }, sections: [], isMainPage: false, - userCanUpload: mw.config.get( 'wgUserCanUpload' ) + userCanUpload: mw.config.get( 'wgUserCanUpload' ), + hash: window.location.hash }, /** @@ -187,6 +189,21 @@ }, /** + * @inheritdoc + */ + postRender: function () { + var self = this; + // Restore anchor position after everything on page has been loaded. + // Otherwise, images that load after a while will push the anchor + // from the top of the viewport. + if ( this.options.hash ) { + $( window ).on( 'load', function () { + window.location.hash = self.options.hash; + } ); + } + }, + + /** * Return reference section * @method */ -- To view, visit https://gerrit.wikimedia.org/r/195596 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9ca5272a96055c14713949bfc77a4a5f776c599f Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org> Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Phuedx <g...@samsmith.io> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits