Skip to content

Commit

Permalink
Add speed controls
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccollum-woolpert committed Mar 29, 2024
1 parent ba153b8 commit bcc1bb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@
(click)="!animationTimer$ || animationTimer$.closed ? onBeginAnimate() : onEndAnimate()">
{{ !animationTimer$ || animationTimer$.closed ? 'Animate routes' : 'Stop animating routes' }}
</button>
<mat-form-field appearance="fill">
<mat-label>Speed</mat-label>
<mat-select [(value)]="animationSpeedMultiple">
<mat-option [value]="1"> Slow </mat-option>
<mat-option [value]="3"> Normal </mat-option>
<mat-option [value]="6"> Fast </mat-option>
</mat-select>
</mat-form-field>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class TravelSimulatorComponent implements OnInit, OnDestroy {
timezoneOffset: number;
valueChanged = new Subject<number>();
animationTimer$: Subscription;
animationSpeedMultiple = 3;

formatSecondsDate = formatSecondsDate;

Expand Down Expand Up @@ -80,12 +81,12 @@ export class TravelSimulatorComponent implements OnInit, OnDestroy {
onBeginAnimate(): void {
this.timeSlider.disabled = true;
this.animationTimer$ = interval(100).subscribe((_value) => {
const newTime = this.timeSlider.value + 60;
const newTime = this.timeSlider.value + 60 * this.animationSpeedMultiple;
if (newTime > this.timeSlider.max) {
this.onEndAnimate();
return;
}
this.valueChanged.next(this.timeSlider.value + 60);
this.valueChanged.next(newTime);
});
}

Expand Down

0 comments on commit bcc1bb1

Please sign in to comment.