Skip to content

Commit

Permalink
Use layoutStrategy so that the KeyboardHelpDialog is constrained to t…
Browse files Browse the repository at this point in the history
…he simulation bounds, see #546
  • Loading branch information
jessegreenberg committed Dec 19, 2018
1 parent 437a08a commit 428b7a2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions js/KeyboardHelpDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ define( function( require ) {
function KeyboardHelpDialog( helpContent, options ) {
var self = this;

// get the screen width for the screenView that is currently being displayed, then we can set the maxWidth accordingly.
var screenWidth = phet.joist.sim && phet.joist.sim.currentScreenProperty &&
phet.joist.sim.currentScreenProperty.get() &&
phet.joist.sim.currentScreenProperty.get().view &&
phet.joist.sim.currentScreenProperty.get().view.layoutBounds.width || 1000;

options = _.extend( {
titleAlign: 'center',
fill: 'rgb( 214, 237, 249 )',
ySpacing: 15,
tandem: Tandem.required,

// empirically determined to have some margin relative to max width
maxWidth: .73 * screenWidth
// the width of the KeyboardHelpDialog is constrained to the simulation bounds
layoutStrategy: function( dialog, simBounds, screenBounds, scale ) {

// empirically determined to have some margin relative to max width
dialog.maxWidth = ( simBounds.width / scale ) * 0.90;

// this is the default layout strategy in Dialog
dialog.center = simBounds.center.times( 1.0 / scale );
}
}, options );

// title
Expand Down

0 comments on commit 428b7a2

Please sign in to comment.