diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js index 0736f832a..b7ea46dd7 100644 --- a/resources/mmv/mmv.js +++ b/resources/mmv/mmv.js @@ -44,6 +44,7 @@ const ThumbnailWidthCalculator = require( './mmv.ThumbnailWidthCalculator.js' ); const { extensions, useThumbnailGuessing } = require( './config.json' ); const router = require( 'mediawiki.router' ); +let comingFromHashChange = false; /** * Analyses the page, looks for image content and sets up the hooks @@ -95,7 +96,7 @@ class MultimediaViewer { */ this.router = router; this.setupRouter(); - this.comingFromHashChange = false; + comingFromHashChange = false; /** * UI object used to display the pictures in the page. @@ -685,8 +686,8 @@ class MultimediaViewer { this.viewLogger.recordViewDuration(); this.viewLogger.unattach(); - if ( this.comingFromHashChange ) { - this.comingFromHashChange = false; + if ( comingFromHashChange ) { + comingFromHashChange = false; } else { this.router.back(); } @@ -706,7 +707,7 @@ class MultimediaViewer { // handle empty hashes, and anchor links (page sections, possibly including /) this.router.addRoute( /.*$/, () => { if ( this.isOpen ) { - this.comingFromHashChange = true; + comingFromHashChange = true; document.title = this.createDocumentTitle( null ); if ( this.ui ) { // FIXME triggers mmv-close event, which calls viewer.close()