Skip to content

Commit

Permalink
fix for #315
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 12, 2022
1 parent cf0c462 commit d3cf7c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/common/model/PopulationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ class PopulationModel extends PhetioObject {

// Scrolls the x-axis so that 'now' is always the max x value. unlink is not necessary.
timeInGenerationsProperty.link( timeInGeneration => {
const max = Math.max( options.xAxisLength, timeInGeneration );
if ( this.xRangeProperty.value.max !== max ) {
const min = max - options.xAxisLength;
this.xRangeProperty.value = new Range( min, max );

// Skip when restoring PhET-iO state, see https://github.com/phetsims/natural-selection/issues/315
if ( !phet.joist.sim.isSettingPhetioStateProperty.value ) {
const max = Math.max( options.xAxisLength, timeInGeneration );
if ( this.xRangeProperty.value.max !== max ) {
const min = max - options.xAxisLength;
this.xRangeProperty.value = new Range( min, max );
}
}
} );

Expand Down

0 comments on commit d3cf7c4

Please sign in to comment.