Skip to content

Commit

Permalink
Add comments. See #80.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luisav1 committed Jul 25, 2023
1 parent 22ad309 commit 7c7cc62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions js/chart-intro/view/DecayEquationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ class DecayEquationNode extends VBox {
equationHBox.setChildren( [ stableText ] );
decayLikelihoodPercentText.visible = false;

// re-center the stable text at the horizontal center of the mostLikelyDecayText whenever the text changes length due to a language change
stableText.boundsProperty.link( () => {

// how the mostLikelyDecayText sits relative to DecayEquationNode
const mostLikelyDecayTextGlobalCenter = mostLikelyDecayHBox.localToGlobalPoint( mostLikelyDecayText.center );

// translate the global center of the mostLikelyDecayText to the equationHBox coordinate frame
const mostLikelyDecayTextLocalPointCenter = equationHBox.globalToLocalPoint( mostLikelyDecayTextGlobalCenter );

const leftMargin = mostLikelyDecayTextLocalPointCenter.x - stableText.width / 2;
stableText.setLayoutOptions( { leftMargin: leftMargin } );
} );
Expand Down

0 comments on commit 7c7cc62

Please sign in to comment.