Skip to content

Commit

Permalink
Reset map view when activating travel simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccollum-woolpert committed Jul 29, 2024
1 parent 0cdf888 commit 2b988c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import TravelSimulatorSelectors from '../../selectors/travel-simulator.selectors';
import { MaterialModule } from 'src/app/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MapService } from '../../services';
import { MockMapService } from 'src/test/service-mocks';

describe('TravelSimulatorComponent', () => {
let component: TravelSimulatorComponent;
Expand All @@ -32,6 +34,7 @@ describe('TravelSimulatorComponent', () => {
imports: [MaterialModule, NoopAnimationsModule],
declarations: [TravelSimulatorComponent],
providers: [
{ provide: MapService, useValue: MockMapService },
provideMockStore({
selectors: [
{ selector: ShipmentModelSelectors.selectGlobalStartTime, value: 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { setActive, setTime } from '../../actions/travel-simulator.actions';
import TravelSimulatorSelectors from '../../selectors/travel-simulator.selectors';
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import { formatSecondsDate } from 'src/app/util/time-translation';
import { MapService } from '../../services';

@Component({
selector: 'app-travel-simulator',
Expand Down Expand Up @@ -58,7 +59,11 @@ export class TravelSimulatorComponent implements OnInit, OnDestroy {

formatSecondsDate = formatSecondsDate;

constructor(private store: Store, private detectorRef: ChangeDetectorRef) {}
constructor(
private store: Store,
private detectorRef: ChangeDetectorRef,
private map: MapService
) {}

ngOnInit(): void {
this.end$ = this.store
Expand Down Expand Up @@ -102,7 +107,9 @@ export class TravelSimulatorComponent implements OnInit, OnDestroy {
onToggleActive(event: MatSlideToggleChange): void {
this.store.dispatch(setActive({ active: event.checked }));

if (!event.checked) {
if (event.checked) {
this.map.zoomToHome();
} else {
this.onEndAnimate();
}
}
Expand Down

0 comments on commit 2b988c1

Please sign in to comment.