phetsims / gene-expression-essentials

An educational simulation about how genes work to create proteins.
GNU General Public License v3.0
4 stars 6 forks source link

adding transcription factors to BiomoleculeToolBoxNode #72

Closed jbphet closed 7 years ago

jbphet commented 7 years ago

First off, there is something that just looks odd in this code, but the box itself looks okay, so I'm not sure what's going on. Here is the code snippet:

    var negativeTranscriptBoxNodes = [];
    for ( i = 0; i < transcriptionFactors.length; i++ ) {
      tfConfig = transcriptionFactors[ i ];
      if ( !tfConfig.isPositive ) {
        var negativeTranscriptionBox = new HBox( {
          children: [
            negativeTranscriptionFactorLabel,
            new Spacer( maxWidth - negativeTranscriptionFactorLabelWidth, 0 ),
            this.addCreatorNode( new TranscriptionFactorCreatorNode( this, tfConfig ) )
          ],
          spacing: 10
        } );
        negativeTranscriptBoxNodes.push( positiveTranscriptionBox );
      }
    }

Note that the loop is creating negativeTranscriptionBox but then is pushing positiveTranscriptionBox onto the list of negativeTrascriptBoxNodes. I'm not sure how this is working, but it looks wrong.

Second, both places where transcription factors are added should probably be done as closures rather than as looks. The code would be a bit cleaner.

aadish commented 7 years ago

e9b03097f2c3d7911932567ea0db42e101b6080f fixed by this commit