From aa35b5e50e3826f0f546efcc9e67258e7a919266 Mon Sep 17 00:00:00 2001 From: samreid Date: Fri, 12 Feb 2021 20:14:13 -0700 Subject: [PATCH] Unlink from schematicTypeProperty, see https://github.com/phetsims/circuit-construction-kit-common/issues/660 --- js/view/CCKCLightBulbNode.js | 6 ++++-- js/view/FuseNode.js | 6 ++++-- js/view/ResistorNode.js | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/view/CCKCLightBulbNode.js b/js/view/CCKCLightBulbNode.js index f2389ff8..2c15b8c6 100644 --- a/js/view/CCKCLightBulbNode.js +++ b/js/view/CCKCLightBulbNode.js @@ -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 ) { @@ -249,6 +250,7 @@ class CCKCLightBulbNode extends FixedCircuitElementNode { circuitLayerNode && circuitLayerNode.removeChildFromBackground( this.rayNodeContainer ); viewTypeProperty.unlink( viewListener ); this.socketNode.dispose(); + schematicTypeProperty.unlink( updateSchematicType ); }; } diff --git a/js/view/FuseNode.js b/js/view/FuseNode.js index 1845c9d4..af1f59d4 100644 --- a/js/view/FuseNode.js +++ b/js/view/FuseNode.js @@ -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; @@ -184,6 +185,7 @@ class FuseNode extends FixedCircuitElementNode { if ( !options.isIcon ) { this.fuse.isTrippedProperty.unlink( updateTripped ); } + schematicTypeProperty.unlink( updateSchematicType ); }; } diff --git a/js/view/ResistorNode.js b/js/view/ResistorNode.js index 403ca60e..7cd47393 100644 --- a/js/view/ResistorNode.js +++ b/js/view/ResistorNode.js @@ -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; @@ -226,6 +227,7 @@ class ResistorNode extends FixedCircuitElementNode { this.disposeResistorNode = () => { updateColorBands && resistor.resistanceProperty.unlink( updateColorBands ); lifelikeResistorImageNode.dispose(); + schematicTypeProperty.unlink( updateSchematicType ); }; }