Skip to content

Commit

Permalink
Remove unlinkAttribute, see phetsims/chipper#1313
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Aug 26, 2022
1 parent 22c574f commit 30251cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions js/common/view/CoinTermHaloNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class CoinTermHaloNode extends Node {
// control coin halo visibility
const coinHaloVisibleProperty = new DerivedProperty( [ viewModeProperty, coinTerm.combineHaloActiveProperty ],
( viewMode, combineHaloActive ) => ( viewMode === ViewMode.COINS ) && combineHaloActive );
const coinHaloVisibilityObserver = coinHaloVisibleProperty.linkAttribute( coinHalo, 'visible' );
const coinHaloVisibilityObserver = visible => {coinHalo.visible = visible;};
coinHaloVisibleProperty.link( coinHaloVisibilityObserver );

// add the term halo
const termHalo = new Circle( EESharedConstants.TERM_COMBINE_DISTANCE, {
Expand All @@ -62,7 +63,7 @@ class CoinTermHaloNode extends Node {
coinTerm.positionProperty.link( handlePositionChanged );

this.disposeCoinTermHaloNode = () => {
coinHaloVisibleProperty.unlinkAttribute( coinHaloVisibilityObserver );
coinHaloVisibleProperty.unlink( coinHaloVisibilityObserver );
coinHaloVisibleProperty.dispose();
termHaloVisibleMultilink.dispose();
coinTerm.positionProperty.unlink( handlePositionChanged );
Expand Down
10 changes: 6 additions & 4 deletions js/common/view/ExpressionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ class ExpressionNode extends Node {
expression.upperLeftCornerProperty.link( updatePosition );

// update the visibility of the left and right hints
const leftHintHandle = expression.leftHintActiveProperty.linkAttribute( leftHintNode, 'visible' );
const rightHintHandle = expression.rightHintActiveProperty.linkAttribute( rightHintNode, 'visible' );
const leftHintHandle = visible => {leftHintNode.visible = visible;};
const rightHintHandle = visible => {rightHintNode.visible = visible;};
expression.leftHintActiveProperty.link( leftHintHandle );
expression.rightHintActiveProperty.link( rightHintHandle );

// turn the halo on and off based on the associated property
function activateCombineHint( combineHintActive ) {
Expand Down Expand Up @@ -193,8 +195,8 @@ class ExpressionNode extends Node {
expression.layoutChangedEmitter.removeListener( updateBackgroundAndSymbols );
updateBackgroundAndSymbolsMultilink.dispose();
expression.upperLeftCornerProperty.unlink( updatePosition );
expression.leftHintActiveProperty.unlinkAttribute( leftHintHandle );
expression.rightHintActiveProperty.unlinkAttribute( rightHintHandle );
expression.leftHintActiveProperty.unlink( leftHintHandle );
expression.rightHintActiveProperty.unlink( rightHintHandle );
expression.combineHaloActiveProperty.unlink( activateCombineHint );
leftHintMultilink.dispose();
rightHintMultilink.dispose();
Expand Down
5 changes: 3 additions & 2 deletions js/common/view/ExpressionOverlayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class ExpressionOverlayNode extends Node {
);

// update the expression's position as this node moves
const translationLinkHandle = expression.upperLeftCornerProperty.linkAttribute( this, 'translation' );
const translationLinkHandle = position => {this.translation = position;};
expression.upperLeftCornerProperty.link( translationLinkHandle );

// become invisible if the expression goes into edit mode so that the user can interact with the coin terms within
function updateVisibility( inEditMode ) {
Expand Down Expand Up @@ -197,7 +198,7 @@ class ExpressionOverlayNode extends Node {
this.disposeExpressionOverlayNode = () => {
editExpressionButton.dispose();
breakApartButton.dispose();
expression.upperLeftCornerProperty.unlinkAttribute( translationLinkHandle );
expression.upperLeftCornerProperty.unlink( translationLinkHandle );
expression.inEditModeProperty.unlink( updateVisibility );
updateShapeMultilink.dispose();
updateDragHandlerAttachmentMultilink.dispose();
Expand Down

0 comments on commit 30251cf

Please sign in to comment.