Skip to content

Commit

Permalink
add missing tandems, #205
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Nov 2, 2023
1 parent 26096eb commit ba94c32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/common/model/KeplersLawsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class KeplersLawsModel extends SolarSystemCommonModel<EllipticalOrbitEngine> {
tandem: options.tandem.createTandem( 'stopwatch' )
} );

this.periodTracker = new PeriodTracker( this );
this.periodTracker = new PeriodTracker( this, options.tandem.createTandem( 'periodTracker' ) );

const animatedZoomScaleRange = new Range( 45, 100 );
const animatedZoomScaleProperty = new NumberProperty( animatedZoomScaleRange.min, {
Expand Down
15 changes: 11 additions & 4 deletions js/common/model/PeriodTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Range from '../../../../dot/js/Range.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import KeplersLawsModel from './KeplersLawsModel.js';
import Emitter from '../../../../axon/js/Emitter.js';
import Tandem from '../../../../tandem/js/Tandem.js';

export class TrackingState extends EnumerationValue {
public static readonly IDLE = new TrackingState();
Expand All @@ -38,10 +39,14 @@ export default class PeriodTracker {

public readonly fadingDuration = 3;

public constructor( private readonly model: Pick<KeplersLawsModel, 'engine' | 'timeProperty' | 'isPlayingProperty'> ) {
public constructor( private readonly model: Pick<KeplersLawsModel, 'engine' | 'timeProperty' | 'isPlayingProperty'>, tandem: Tandem ) {
this.trackingState = TrackingState.IDLE;

const periodRangeProperty = new Property<Range>( new Range( 0, 1 ) );
const periodRangeProperty = new Property<Range>( new Range( 0, 1 ), {
tandem: tandem.createTandem( 'periodRangeProperty' ),
phetioReadOnly: true
} );

this.model.engine.periodProperty.link( period => {
periodRangeProperty.value.max = period;
} );
Expand All @@ -50,14 +55,16 @@ export default class PeriodTracker {
position: Vector2.ZERO,
timePropertyOptions: {
range: new Range( 0, this.fadingDuration )
}
},
tandem: tandem.createTandem( 'fadingTimer' )
} );

this.periodTimer = new Stopwatch( {
position: new Vector2( 500, 50 ),
timePropertyOptions: {
range: periodRangeProperty
}
},
tandem: tandem.createTandem( 'periodTimer' )
} );
this.periodTimer.isRunningProperty.link( isRunning => {
if ( isRunning ) {
Expand Down

0 comments on commit ba94c32

Please sign in to comment.