Skip to content

Commit

Permalink
fix layout of coordinate relative to quadratic, #207
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Apr 9, 2024
1 parent 275b728 commit e8f5a72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions js/common/view/GQManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import { Node, TColor } from '../../../../scenery/js/imports.js';
import graphingQuadratics from '../../graphingQuadratics.js';
import CoordinatesNode from './CoordinatesNode.js';
import Multilink from '../../../../axon/js/Multilink.js';

// Positions the coordinates relative to the sphere
type LayoutCoordinatesFunction = ( coordinates: Vector2 | null, coordinatesNode: Node, radius: number ) => void;
Expand Down Expand Up @@ -50,6 +51,7 @@ export default class GQManipulator extends Manipulator {
const options = optionize<GQManipulatorOptions, SelfOptions, ManipulatorOptions>()( {

// SelfOptions
isDisposable: false,
radius: 10,
color: 'black',
coordinatesBackgroundColor: 'black',
Expand Down Expand Up @@ -80,8 +82,8 @@ export default class GQManipulator extends Manipulator {
this.addChild( coordinatesNode );

// Update layout
coordinatesNode.boundsProperty.link( () =>
options.layoutCoordinates( coordinatesProperty.value, coordinatesNode, actualRadius ) );
Multilink.multilink( [ coordinatesProperty, coordinatesNode.boundsProperty ],
( coordinates, bounds ) => options.layoutCoordinates( coordinates, coordinatesNode, actualRadius ) );
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/standardform/view/PointNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import { Circle, Node, NodeOptions, NodeTranslationOptions, TColor } from '../../../../scenery/js/imports.js';
import CoordinatesNode from '../../common/view/CoordinatesNode.js';
import graphingQuadratics from '../../graphingQuadratics.js';
import Multilink from '../../../../axon/js/Multilink.js';

// Positions the coordinates relative to the point
type LayoutCoordinatesFunction = ( coordinatesNode: Node, pointNode: Node ) => void;
Expand Down Expand Up @@ -83,7 +84,8 @@ export default class PointNode extends Node {
super( options );

// Update layout
coordinatesNode.boundsProperty.link( () => options.layoutCoordinates( coordinatesNode, pointNode ) );
Multilink.multilink( [ coordinatesProperty, coordinatesNode.boundsProperty ],
( coordinates, bounds ) => options.layoutCoordinates( coordinatesNode, pointNode ) );
}
}

Expand Down

0 comments on commit e8f5a72

Please sign in to comment.