Skip to content

Commit

Permalink
add missing dependency for AncillaryTool point Properties, #310, #307
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 24, 2023
1 parent baab2e7 commit aef8d03
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion js/common/model/AncillaryTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ export default class AncillaryTool extends PhetioObject {

/**
* As the xProperty for a curve changes, provide the corresponding CurvePoint.
* Note that curve.pointsProperty may also be changed via PhET-iO, see https://github.com/phetsims/calculus-grapher/issues/307.
* Return type is ReadOnlyProperty so that we can call notifyListenersStatic.
*/
function createCurvePointProperty( curve: Curve, xProperty: TReadOnlyProperty<number> ): ReadOnlyProperty<CurvePoint> {
return new DerivedProperty( [ xProperty ], x => curve.getClosestPointAt( x ) );
return new DerivedProperty( [ curve.pointsProperty, xProperty ], ( points, x ) => curve.getClosestPointAt( x ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/Curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Curve extends PhetioObject {
// The collection of points that describe the curve. This is an array of CurvePoint instances that are typically
// mutated in place, so that we have acceptable performance. If Curve was instantiated with pointsPropertyReadOnly:false,
// then it is possible to set pointsProperty via PhET-iO.
private readonly pointsProperty: Property<CurvePoint[]>;
public readonly pointsProperty: Property<CurvePoint[]>;

// Using an observable Property for the y-value was considered, but it was deemed to be
// invasive to the performance of the simulation as observers had to listen to the yProperty
Expand Down

0 comments on commit aef8d03

Please sign in to comment.