From 18d2b5075aac49cf9c301370e0f38bb77935d353 Mon Sep 17 00:00:00 2001 From: Marla Schulz Date: Wed, 8 Jun 2022 11:50:03 -0600 Subject: [PATCH] Close all valves when sync button is clicked, see: https://github.com/phetsims/mean-share-and-balance/issues/3 --- js/intro/model/IntroModel.ts | 2 +- js/intro/model/PipeModel.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/intro/model/IntroModel.ts b/js/intro/model/IntroModel.ts index 2cd518a6..f3c6ff4e 100644 --- a/js/intro/model/IntroModel.ts +++ b/js/intro/model/IntroModel.ts @@ -215,8 +215,8 @@ export default class IntroModel extends MeanShareAndBalanceModel { public override syncData(): void { super.syncData(); - // Will trigger the closure of al pipes. pipe.isOpenProperty = false this.isAutoSharingProperty.set( false ); + this.pipeGroup.forEach( pipe => pipe.isOpenProperty.set( false ) ); this.matchCupWaterLevels(); } diff --git a/js/intro/model/PipeModel.ts b/js/intro/model/PipeModel.ts index d865923c..519ccb13 100644 --- a/js/intro/model/PipeModel.ts +++ b/js/intro/model/PipeModel.ts @@ -29,7 +29,7 @@ export type PipeModelOptions = SelfOptions & PhetioObjectOptions; export default class PipeModel extends PhetioObject { public readonly isOpenProperty: BooleanProperty; - public readonly isCurrentlyClickedProperty: BooleanProperty; + public readonly isCurrentlyClickedProperty= new BooleanProperty( false ); public readonly x: number; public readonly y: number; public static PipeModelIO: IOType; @@ -47,14 +47,15 @@ export default class PipeModel extends PhetioObject { this.isOpenProperty = new BooleanProperty( options.isOpen, { tandem: options.tandem.createTandem( 'isOpenProperty' ) } ); + this.x = options.x; this.y = options.y; - this.isCurrentlyClickedProperty = new BooleanProperty( false ); } public override dispose(): void { super.dispose(); this.isOpenProperty.dispose(); + this.isCurrentlyClickedProperty.dispose(); } }