Skip to content

Commit

Permalink
reset Slope equation elements to (0,0), fix Multilink dependencies, #152
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Apr 11, 2024
1 parent 45848ab commit 4f7dd86
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions js/slope/view/SlopeEquationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,12 @@ class DynamicLabelNode extends EquationNode {

const lineColor = line.color;

// start with all children invisible
const len = this.children.length;
for ( let i = 0; i < len; i++ ) {
this.children[ i ].visible = false;
}
// Start with all elements invisible and at (0,0).
this.children.forEach( child => {
child.visible = false;
child.x = 0;
child.y = 0;
} );

// 'Slope is'
slopeIsText.visible = true;
Expand Down Expand Up @@ -491,11 +492,8 @@ class DynamicLabelNode extends EquationNode {
}
};

const multilink = new Multilink( [
lineProperty,
slopeIsText.boundsProperty, // links to a StringProperty, and layout is handled in this.update
GraphingLinesStrings.undefinedStringProperty // used in this.update
],
// If the line changes, or any element that is listening to a LocalizedStringProperty changes, then update.
const multilink = new Multilink( [ lineProperty, slopeIsText.localBoundsProperty, riseText.localBoundsProperty ],
line => update( line )
);

Expand Down

0 comments on commit 4f7dd86

Please sign in to comment.