Fix Chrome bug where popstate could still reset scroll position

Change-Id: I3418b2e446a210a406daacc1321103df1f09caa1
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/486
This commit is contained in:
Gilles Dubuc 2014-04-23 02:26:07 +02:00
parent 7ac4b375b6
commit 292f42dc7c

View file

@ -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 );
}
};