Skip to content

Commit

Permalink
Fractions multilink fixes, see phetsims/axon#395
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed May 24, 2022
1 parent ace7680 commit 470e7d6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
3 changes: 2 additions & 1 deletion js/building/model/ShapePiece.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import Multilink from '../../../../axon/js/Multilink.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
Expand Down Expand Up @@ -96,7 +97,7 @@ class ShapePiece {

// Handle rotational animation towards a target (if any)
// No need to unlink, as we own the given Properties
Property.multilink( [ this.isUserControlledProperty, this.targetRotationProperty ], ( isUserControlled, targetRotation ) => {
Multilink.multilink( [ this.isUserControlledProperty, this.targetRotationProperty ], ( isUserControlled, targetRotation ) => {
if ( isUserControlled ) {
const currentRotation = this.rotationProperty.value;
this.trueTargetRotation = Animator.modifiedEndAngle( currentRotation, this.targetRotationProperty.value );
Expand Down
12 changes: 4 additions & 8 deletions js/building/view/NumberGroupNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
*/

import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import { Shape } from '../../../../kite/js/imports.js';
import merge from '../../../../phet-core/js/merge.js';
import { Line } from '../../../../scenery/js/imports.js';
import { Node } from '../../../../scenery/js/imports.js';
import { Path } from '../../../../scenery/js/imports.js';
import { Rectangle } from '../../../../scenery/js/imports.js';
import { Text } from '../../../../scenery/js/imports.js';
import { Line, Node, Path, Rectangle, Text } from '../../../../scenery/js/imports.js';
import FractionsCommonConstants from '../../common/FractionsCommonConstants.js';
import FractionsCommonColors from '../../common/view/FractionsCommonColors.js';
import fractionsCommon from '../../fractionsCommon.js';
Expand Down Expand Up @@ -67,7 +63,7 @@ class NumberGroupNode extends GroupNode {
lineWidth: 3,
center: outline.center
} );
this.itemsToDispose.push( Property.multilink( [ spot.pieceProperty, spot.showNotAllowedProperty ], ( piece, notAllowed ) => {
this.itemsToDispose.push( Multilink.multilink( [ spot.pieceProperty, spot.showNotAllowedProperty ], ( piece, notAllowed ) => {
if ( piece !== null ) {
text.text = piece.number;
text.center = outline.center;
Expand Down Expand Up @@ -128,7 +124,7 @@ class NumberGroupNode extends GroupNode {
this.numberGroup.hasDoubleDigitsProperty.link( this.fractionLineLengthListener );

// @private {function}
this.undoVisibilityListener = Property.multilink( [ numberGroup.hasPiecesProperty, this.isSelectedProperty ], ( hasPieces, isSelected ) => {
this.undoVisibilityListener = Multilink.multilink( [ numberGroup.hasPiecesProperty, this.isSelectedProperty ], ( hasPieces, isSelected ) => {
this.returnButton.visible = hasPieces && isSelected;
} );
this.itemsToDispose.push( this.undoVisibilityListener );
Expand Down
4 changes: 2 additions & 2 deletions js/building/view/NumberPieceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Jonathan Olson <[email protected]>
*/

import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import merge from '../../../../phet-core/js/merge.js';
import { DragListener } from '../../../../scenery/js/imports.js';
Expand Down Expand Up @@ -74,7 +74,7 @@ class NumberPieceNode extends Node {
}

// @private {function}
this.visibilityListener = Property.multilink( [
this.visibilityListener = Multilink.multilink( [
numberPiece.isUserControlledProperty,
numberPiece.isAnimatingProperty
], ( isUserControlled, isAnimating ) => {
Expand Down
4 changes: 2 additions & 2 deletions js/building/view/ShapePieceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Jonathan Olson <[email protected]>
*/

import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import { Shape } from '../../../../kite/js/imports.js';
import merge from '../../../../phet-core/js/merge.js';
Expand Down Expand Up @@ -120,7 +120,7 @@ class ShapePieceNode extends Node {
}

// @private {function}
this.visibilityListener = Property.multilink( [
this.visibilityListener = Multilink.multilink( [
shapePiece.isUserControlledProperty,
shapePiece.isAnimatingProperty
], ( isUserControlled, isAnimating ) => {
Expand Down
4 changes: 2 additions & 2 deletions js/intro/view/EqualityLabScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import MathSymbols from '../../../../scenery-phet/js/MathSymbols.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
Expand Down Expand Up @@ -186,7 +186,7 @@ class EqualityLabScreenView extends ContainerSetScreenView {
FractionsCommonColors.equalityLabColorProperty
], color => color.withAlpha( 0.8 ) );

Property.multilink( [ model.representationProperty, model.showNumberLineProperty ], ( representation, showNumberLine ) => {
Multilink.multilink( [ model.representationProperty, model.showNumberLineProperty ], ( representation, showNumberLine ) => {
representation = showNumberLine ? IntroRepresentation.NUMBER_LINE : representation;
if ( representation !== lastRepresentation ) {
containerNodes.forEach( containerNode => containerNode.dispose() );
Expand Down
4 changes: 2 additions & 2 deletions js/intro/view/beaker/BeakerContainerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Jonathan Olson <[email protected]>
*/

import Property from '../../../../../axon/js/Property.js';
import Multilink from '../../../../../axon/js/Multilink.js';
import { DragListener } from '../../../../../scenery/js/imports.js';
import fractionsCommon from '../../../fractionsCommon.js';
import ContainerNode from '../ContainerNode.js';
Expand All @@ -21,7 +21,7 @@ class BeakerContainerNode extends ContainerNode {
super( container, options );

// @private {Multilink}
this.multilink = Property.multilink( [ container.appearsFilledCellCountProperty, container.cells.lengthProperty ], ( numerator, denominator ) => {
this.multilink = Multilink.multilink( [ container.appearsFilledCellCountProperty, container.cells.lengthProperty ], ( numerator, denominator ) => {
// Sanity, if these get modified out of order (very possible)
numerator = Math.min( numerator, denominator );

Expand Down
8 changes: 4 additions & 4 deletions js/intro/view/numberline/NumberLineNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import NumberProperty from '../../../../../axon/js/NumberProperty.js';
import Property from '../../../../../axon/js/Property.js';
import Multilink from '../../../../../axon/js/Multilink.js';
import Bounds2 from '../../../../../dot/js/Bounds2.js';
import Utils from '../../../../../dot/js/Utils.js';
import { Shape } from '../../../../../kite/js/imports.js';
Expand Down Expand Up @@ -174,7 +174,7 @@ class NumberLineNode extends Node {
this.containerCountProperty.link( this.containerCountListener );

// @private {Multilink}
this.minorTickMultilink = Property.multilink( [
this.minorTickMultilink = Multilink.multilink( [
denominatorProperty,
containerCountProperty
], ( denominator, containerCount ) => {
Expand All @@ -194,7 +194,7 @@ class NumberLineNode extends Node {
} );

// @private {Multilink}
this.multipliedTickMultilink = Property.multilink( [
this.multipliedTickMultilink = Multilink.multilink( [
denominatorProperty,
containerCountProperty,
options.multiplierProperty
Expand All @@ -216,7 +216,7 @@ class NumberLineNode extends Node {
} );

// @private {Multilink}
this.markerMultilink = Property.multilink( [
this.markerMultilink = Multilink.multilink( [
numeratorProperty,
denominatorProperty
], ( numerator, denominator ) => {
Expand Down
3 changes: 2 additions & 1 deletion js/matching/model/MatchingChallenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import Emitter from '../../../../axon/js/Emitter.js';
import Multilink from '../../../../axon/js/Multilink.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import dotRandom from '../../../../dot/js/dotRandom.js';
Expand Down Expand Up @@ -192,7 +193,7 @@ class MatchingChallenge {

// @private {Array.<MatchPiece>}
this.lastFailedPair = [];
Property.multilink( this.scaleSpots.map( scaleSpot => scaleSpot.pieceProperty ), ( leftPiece, rightPiece ) => {
Multilink.multilink( this.scaleSpots.map( scaleSpot => scaleSpot.pieceProperty ), ( leftPiece, rightPiece ) => {
if ( !leftPiece || !rightPiece ) {
this.stateProperty.value = MatchingChallenge.State.NO_COMPARISON;
}
Expand Down

0 comments on commit 470e7d6

Please sign in to comment.