diff --git a/resources/mmv/mmv.bootstrap.js b/resources/mmv/mmv.bootstrap.js index 293600e42..9e5448a3d 100755 --- a/resources/mmv/mmv.bootstrap.js +++ b/resources/mmv/mmv.bootstrap.js @@ -373,6 +373,8 @@ * Cleans up the overlay */ MMVB.cleanupOverlay = function () { + var bootstrap = this; + $( document.body ).removeClass( 'mw-mmv-lightbox-open' ); if ( this.$overlay ) { @@ -380,8 +382,8 @@ } if ( this.savedScroll ) { - $.scrollTo( this.savedScroll, 0 ); - this.savedScroll = undefined; + // setTimeout because otherwise Chrome will scroll back to top after the popstate event handlers run + setTimeout( function() { $.scrollTo( bootstrap.savedScroll, 0 ); bootstrap.savedScroll = undefined; }, 0 ); } };