Skip to content

Commit

Permalink
pass bounds options to mutate at end of constructor, provide options …
Browse files Browse the repository at this point in the history
…arg index to all mixins (and assert), remove unneeded mutate calls next to super, phetsims/scenery#1340
  • Loading branch information
zepumph committed Feb 8, 2022
1 parent 08e414d commit cee0972
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/FaucetNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class FaucetNode extends AccessibleSlider( Node, 0 ) {
SHOOTER_WINDOW_BOUNDS.maxX - SHOOTER_WINDOW_BOUNDS.minX, SHOOTER_WINDOW_BOUNDS.maxY - SHOOTER_WINDOW_BOUNDS.minY,
{ fill: 'rgb(107,107,107)' } );

const boundsRequiredOptionKeys = _.pick( options, Node.REQUIRES_BOUNDS_OPTION_KEYS );
options = _.omit( options, Node.REQUIRES_BOUNDS_OPTION_KEYS );

super( options );

// rendering order
Expand Down Expand Up @@ -282,6 +285,8 @@ class FaucetNode extends AccessibleSlider( Node, 0 ) {
};
enabledProperty.link( enabledObserver );

this.mutate( boundsRequiredOptionKeys );

// flow rate control is visible only when the faucet is interactive
const interactiveObserver = interactive => {
shooterNode.visible = trackNode.visible = interactive;
Expand Down
5 changes: 5 additions & 0 deletions js/SpectrumSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class SpectrumSlider extends AccessibleSlider( Node, 0 ) {
assert && assert( !options.enabledRangeProperty, 'SpectrumSlider sets its own enabledRangeProperty' );
options.enabledRangeProperty = new Property( new Range( options.minValue, options.maxValue ) );

const boundsRequiredOptionKeys = _.pick( options, Node.REQUIRES_BOUNDS_OPTION_KEYS );
options = _.omit( options, Node.REQUIRES_BOUNDS_OPTION_KEYS );

super( options );

const track = new SpectrumNode( {
Expand Down Expand Up @@ -309,6 +312,8 @@ class SpectrumSlider extends AccessibleSlider( Node, 0 ) {
valueProperty.unlink( valueListener );
};

this.mutate( boundsRequiredOptionKeys );

// support for binder documentation, stripped out in builds and only runs when ?binder is specified
assert && phet.chipper.queryParameters.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'SpectrumSlider', this );
}
Expand Down
2 changes: 1 addition & 1 deletion js/keyboard/help/KeyboardHelpSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const OR_TEXT_MAX_WIDTH = 16;
const DEFAULT_LABEL_MAX_WIDTH = 235;
const DEFAULT_HEADING_MAX_WIDTH = 335;

class KeyboardHelpSection extends ReadingBlock( VBox ) {
class KeyboardHelpSection extends ReadingBlock( VBox, 0 ) {

/**
* @param {string} headingString - the translatable label for this content
Expand Down

0 comments on commit cee0972

Please sign in to comment.