Skip to content

Commit

Permalink
step the view only if the sim is playing, #33
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 17, 2024
1 parent b675b97 commit 9372977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions js/energylevels/view/EnergyLevelsScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import EnergyLevelsZoomedInBoxNode from './EnergyLevelsZoomedInBoxNode.js';

export default class EnergyLevelsScreenView extends ScreenView {

private readonly model: EnergyLevelsModel;
private readonly zoomedInBoxNode: EnergyLevelsZoomedInBoxNode;
private readonly electronEnergyLevelAccordionBox: ElectronEnergyLevelAccordionBox;

Expand Down Expand Up @@ -236,13 +237,16 @@ export default class EnergyLevelsScreenView extends ScreenView {
resetAllButton
];

this.model = model;
this.zoomedInBoxNode = zoomedInBoxNode;
this.electronEnergyLevelAccordionBox = electronEnergyLevelAccordionBox;
}

public override step( dt: number ): void {
this.zoomedInBoxNode.step( dt );
this.electronEnergyLevelAccordionBox.step( dt );
if ( this.model.isPlayingProperty.value ) {
this.zoomedInBoxNode.step( dt );
this.electronEnergyLevelAccordionBox.step( dt );
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion js/spectra/view/SpectraScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import SpectraZoomedInBoxNode from './SpectraZoomedInBoxNode.js';

export default class SpectraScreenView extends ScreenView {

private readonly model: SpectraModel;
private readonly zoomedInBoxNode: SpectraZoomedInBoxNode;

public constructor( model: SpectraModel, tandem: Tandem ) {
Expand Down Expand Up @@ -223,11 +224,14 @@ export default class SpectraScreenView extends ScreenView {
resetAllButton
];

this.model = model;
this.zoomedInBoxNode = zoomedInBoxNode;
}

public override step( dt: number ): void {
this.zoomedInBoxNode.step( dt );
if ( this.model.isPlayingProperty.value ) {
this.zoomedInBoxNode.step( dt );
}
}
}

Expand Down

0 comments on commit 9372977

Please sign in to comment.