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