From 4658e39f768e95dedc0cb2d91aad9f5ffe706bdb Mon Sep 17 00:00:00 2001 From: Chris Malley Date: Thu, 5 Apr 2018 19:53:29 -0600 Subject: [PATCH] add option showCallback, https://github.com/phetsims/joist/issues/478 --- js/Dialog.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/Dialog.js b/js/Dialog.js index c2be5089..72196c7e 100644 --- a/js/Dialog.js +++ b/js/Dialog.js @@ -55,7 +55,10 @@ define( function( require ) { closeButtonMargin: 5, // {number} how far away should the close button be from the panel border closeButtonListener: function() { self.hide(); }, - // {function|null} called just before the dialog is hidden, see https://github.com/phetsims/joist/issues/478 + // {function|null} called after the dialog is shown, see https://github.com/phetsims/joist/issues/478 + showCallback: null, + + // {function|null} called after the dialog is hidden, see https://github.com/phetsims/joist/issues/478 hideCallback: null, // pass through to Panel options @@ -81,6 +84,7 @@ define( function( require ) { this.isModal = options.modal; // @private + this.showCallback = options.showCallback; this.hideCallback = options.hideCallback; // see https://github.com/phetsims/joist/issues/293 @@ -267,6 +271,9 @@ define( function( require ) { // In case the window size has changed since the dialog was hidden, we should try layout out again. // See https://github.com/phetsims/joist/issues/362 this.updateLayout(); + + // Do this last + this.showCallback && this.showCallback(); } }, @@ -278,13 +285,14 @@ define( function( require ) { hide: function() { if ( this.isShowing ) { - this.hideCallback && this.hideCallback(); - window.phet.joist.sim.hidePopup( this, this.isModal ); this.isShowing = false; // a11y - when the dialog is hidden, make all ScreenView content visible to assistive technology this.setAccessibleViewsVisible( true ); + + // Do this last + this.hideCallback && this.hideCallback(); } },