Skip to content

Commit

Permalink
use recently refactored API better, see #109
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Mar 8, 2025
1 parent dd0d01e commit a976999
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions js/coins/view/CoinExperimentMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,10 @@ class CoinExperimentMeasurementArea extends VBox {
// The user is ready to make measurements on the coins, so animate the coins for both the single and multi-coin
// experiments from the preparation area to the measurement area.
singleCoinViewManager.startIngressAnimation( false );
if ( sceneModel.coinSet.numberOfActiveCoinsProperty.value === MAX_COINS ) {
maxCoinsViewManager.startIngressAnimation( false );
}
else {
multipleCoinsViewManager.startIngressAnimation( false );
}
const multiCoinViewManager = sceneModel.coinSet.numberOfActiveCoinsProperty.value === MAX_COINS ?
maxCoinsViewManager :
multipleCoinsViewManager;
multiCoinViewManager.startIngressAnimation( false );
}
} );

Expand All @@ -317,27 +315,23 @@ class CoinExperimentMeasurementArea extends VBox {

// Animate a coin from the prep area to the single coin test box to indicate that a new "quantum coin" is
// being prepared for measurement.
if ( sceneModel.coinSet.numberOfActiveCoinsProperty.value === MAX_COINS ) {
maxCoinsViewManager.startIngressAnimation( true );
}
else {
multipleCoinsViewManager.startIngressAnimation( true );
}
const multiCoinViewManager = sceneModel.coinSet.numberOfActiveCoinsProperty.value === MAX_COINS ?
maxCoinsViewManager :
multipleCoinsViewManager;
multiCoinViewManager.startIngressAnimation( true );
}
}
} );

// During normal operation the number of active coins can't change without cycling through the preparation state,
// but during phet-io state setting it can. The following linkage handles this case, and makes sure that the view
// reflects the state of the model.
sceneModel.coinSet.numberOfActiveCoinsProperty.lazyLink( numberOfActiveCoins => {
sceneModel.coinSet.numberOfActiveCoinsProperty.lazyLink( () => {
if ( isSettingPhetioStateProperty.value ) {
if ( numberOfActiveCoins === MAX_COINS ) {
maxCoinsViewManager.startIngressAnimation( false );
}
else {
multipleCoinsViewManager.startIngressAnimation( false );
}
const multiCoinViewManager = sceneModel.coinSet.numberOfActiveCoinsProperty.value === MAX_COINS ?
maxCoinsViewManager :
multipleCoinsViewManager;
multiCoinViewManager.startIngressAnimation( false );
}
} );

Expand Down

0 comments on commit a976999

Please sign in to comment.