From 1a65f198208c9f91d2707ad650af13d7e155e0aa Mon Sep 17 00:00:00 2001 From: jessegreenberg Date: Tue, 11 Jul 2017 20:04:16 -0600 Subject: [PATCH] reuse SpectrumWindowDialog because hide no longer disposes, see phetsims/joist#424 --- js/moleculesandlight/view/MoleculesAndLightScreenView.js | 8 +++++++- js/moleculesandlight/view/SpectrumWindowDialog.js | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/moleculesandlight/view/MoleculesAndLightScreenView.js b/js/moleculesandlight/view/MoleculesAndLightScreenView.js index a96fad51..d14c4aac 100644 --- a/js/moleculesandlight/view/MoleculesAndLightScreenView.js +++ b/js/moleculesandlight/view/MoleculesAndLightScreenView.js @@ -136,6 +136,9 @@ define( function( require ) { // @private var spectrumDiagram = new SpectrumDiagram( tandem.createTandem( 'spectrumDiagram' ) ); + // the spectrum dialog, created lazily because Dialog requires sim bounds during construction + var dialog = null; + // Add the button for displaying the electromagnetic spectrum. Scale down the button content when it gets too // large. This is done to support translations. Max width of this button is the width of the molecule control // panel minus twice the default x margin of a rectangular push button. @@ -149,7 +152,10 @@ define( function( require ) { touchAreaXDilation: 7, touchAreaYDilation: 7, listener: function() { - new SpectrumWindowDialog( spectrumDiagram, tandem.createTandem( 'spectrumWindowDialog' ) ).show(); + if ( !dialog ) { + dialog = new SpectrumWindowDialog( spectrumDiagram, tandem.createTandem( 'spectrumWindowDialog' ) ); + } + dialog.show(); }, tandem: tandem.createTandem( 'showLightSpectrumButton' ) } ); diff --git a/js/moleculesandlight/view/SpectrumWindowDialog.js b/js/moleculesandlight/view/SpectrumWindowDialog.js index 1c00365b..0f2b53b5 100644 --- a/js/moleculesandlight/view/SpectrumWindowDialog.js +++ b/js/moleculesandlight/view/SpectrumWindowDialog.js @@ -74,8 +74,6 @@ define( function( require ) { else { // hide the dialog Dialog.prototype.hide.call( self ); - - self.dispose(); } }; this.shownProperty.lazyLink( shownListener ); @@ -109,7 +107,7 @@ define( function( require ) { */ dispose: function() { this.disposeSpectrumWindowDialog(); - Dialog.prototype.dispose && Dialog.prototype.dispose.call( this ); + Dialog.prototype.dispose.call( this ); } } );