Skip to content

Commit

Permalink
Limit ten frames through visibility, see: phetsims/number-compare#25
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Mar 20, 2023
1 parent da87bcf commit 7a17fd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions js/lab/model/LabModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const HIGHEST_COUNT = 20;
class LabModel implements TModel {
public readonly tenFrames: ObservableArray<TenFrame>;

// Whether the tenFrame icon is pickable by a user or not.
public readonly tenFrameIconPickableProperty: Property<boolean>;
// Whether the tenFrame icon is visible or not.
public readonly tenFrameIconVisibleProperty: Property<boolean>;
public readonly onesPlayArea: CountingPlayArea;
public readonly dogPlayArea: CountingPlayArea;
public readonly applePlayArea: CountingPlayArea;
Expand All @@ -35,7 +35,7 @@ class LabModel implements TModel {
public constructor( tandem: Tandem ) {

this.tenFrames = createObservableArray();
this.tenFrameIconPickableProperty = new BooleanProperty( this.tenFrames.length < NumberSuiteCommonConstants.MAX_AMOUNT_OF_TEN_FRAMES );
this.tenFrameIconVisibleProperty = new BooleanProperty( this.tenFrames.length < NumberSuiteCommonConstants.MAX_AMOUNT_OF_TEN_FRAMES );
this.selectedTenFrameProperty = new Property<TenFrame | null>( null );

// create five different kinds of play areas
Expand Down Expand Up @@ -73,7 +73,7 @@ class LabModel implements TModel {
this.tenFrames.lengthProperty.link( length => {

// Limit the amount of tenFrames a user can add to the screen
this.tenFrameIconPickableProperty.value = length < NumberSuiteCommonConstants.MAX_AMOUNT_OF_TEN_FRAMES;
this.tenFrameIconVisibleProperty.value = length < NumberSuiteCommonConstants.MAX_AMOUNT_OF_TEN_FRAMES;
} );

this.tenFrames.addItemRemovedListener( tenFrame => {
Expand All @@ -98,7 +98,7 @@ class LabModel implements TModel {
this.ballPlayArea.reset();
this.onesPlayArea.reset();
this.tenFrames.clear();
this.tenFrameIconPickableProperty.reset();
this.tenFrameIconVisibleProperty.reset();
}
}

Expand Down
8 changes: 5 additions & 3 deletions js/lab/view/TenFrameCreatorPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ class TenFrameCreatorPanel extends NumberSuiteCommonPanel {
tenFrameNode.dragListener.press( event, tenFrameNode );
} );

model.tenFrameIconPickableProperty.link( pickable => {
iconNode.cursor = pickable ? 'pointer' : 'auto';
iconNode.inputListeners = pickable ? [ dragListener ] : [];
iconNode.cursor = 'pointer';
iconNode.inputListeners = [ dragListener ];

model.tenFrameIconVisibleProperty.link( visible => {
iconNode.visible = visible;
} );

super( creatorNodeBackground, {
Expand Down

0 comments on commit 7a17fd9

Please sign in to comment.