Skip to content

Commit

Permalink
Unlink from schematicTypeProperty, see #660
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 16, 2021
1 parent b48dad6 commit 256193e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions js/view/CCKCLightBulbNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,15 @@ class CCKCLightBulbNode extends FixedCircuitElementNode {
schematicNode.center = lightBulbNode.center.plusXY( 0, 22 );
}

schematicTypeProperty.link( schematicType => {
const updateSchematicType = schematicType => {
if ( options.isIcon ) {
schematicNode.shape = schematicType === SchematicType.IEEE ? ieeeShapeIcon : iecShapeIcon;
}
else {
schematicNode.shape = schematicType === SchematicType.IEEE ? ieeeShapeWithLeads : iecShapeWithLeads;
}
} );
};
schematicTypeProperty.link( updateSchematicType );

// Expand the pointer areas with a defensive copy, see https://github.com/phetsims/circuit-construction-kit-common/issues/310
if ( !options.isIcon ) {
Expand Down Expand Up @@ -249,6 +250,7 @@ class CCKCLightBulbNode extends FixedCircuitElementNode {
circuitLayerNode && circuitLayerNode.removeChildFromBackground( this.rayNodeContainer );
viewTypeProperty.unlink( viewListener );
this.socketNode.dispose();
schematicTypeProperty.unlink( updateSchematicType );
};
}

Expand Down
6 changes: 4 additions & 2 deletions js/view/FuseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ class FuseNode extends FixedCircuitElementNode {
.lineToRelative( boxWidth - 2 * boxLength7th, 0 )
.lineToRelative( 0, -boxHeight );

schematicTypeProperty.link( schematicType => {
const updateSchematicType = schematicType => {
schematicNode.shape = schematicType === SchematicType.IEEE ? schematicShape :
fuseIEC;
} );
};
schematicTypeProperty.link( updateSchematicType );

// Center vertically to match the FixedCircuitElementNode assumption that origin is center left
schematicNode.centerY = 0;
Expand Down Expand Up @@ -184,6 +185,7 @@ class FuseNode extends FixedCircuitElementNode {
if ( !options.isIcon ) {
this.fuse.isTrippedProperty.unlink( updateTripped );
}
schematicTypeProperty.unlink( updateSchematicType );
};
}

Expand Down
6 changes: 4 additions & 2 deletions js/view/ResistorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ class ResistorNode extends FixedCircuitElementNode {
lineWidth: CCKCConstants.SCHEMATIC_LINE_WIDTH
} );

schematicTypeProperty.link( schematicType => {
const updateSchematicType = schematicType => {
schematicNode.shape = schematicType === SchematicType.IEEE ? ieeeSchematicShape :
iecSchematicShape;
} );
};
schematicTypeProperty.link( updateSchematicType );

schematicNode.mouseArea = schematicNode.localBounds;
schematicNode.touchArea = schematicNode.localBounds;
Expand Down Expand Up @@ -226,6 +227,7 @@ class ResistorNode extends FixedCircuitElementNode {
this.disposeResistorNode = () => {
updateColorBands && resistor.resistanceProperty.unlink( updateColorBands );
lifelikeResistorImageNode.dispose();
schematicTypeProperty.unlink( updateSchematicType );
};
}

Expand Down

0 comments on commit 256193e

Please sign in to comment.