Skip to content

Commit dca632a

Browse files
committed
Set the viewBox on the dashed path SVG dynamically.
Fixes #142
1 parent 4346cff commit dca632a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/app/game-screen/game-content/game-tabs/game-tab-map/game-tab-map.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { watchAnimations } from './watch-animations';
5757
</div>
5858
}
5959
</div>
60-
<svg class="dashed-path" viewBox="0 0 300 450" preserveAspectRatio="none">
60+
<svg #dashedPathSvg class="dashed-path" viewBox="0 0 300 450" preserveAspectRatio="none">
6161
<path #dashedPath fill="none" stroke="red" stroke-width="1" stroke-dasharray="3 1" d="">
6262
<animate
6363
id="animate-stroke-dashoffset"
@@ -352,6 +352,7 @@ export class GameTabMap {
352352

353353
protected readonly outerDiv = viewChild.required<ElementRef<HTMLDivElement>>('outer');
354354
protected readonly dashedPath = viewChild.required<ElementRef<SVGPathElement>>('dashedPath');
355+
protected readonly dashedPathSvg = viewChild.required<ElementRef<SVGSVGElement>>('dashedPathSvg');
355356
protected readonly overlay = viewChild.required(CdkConnectedOverlay);
356357
protected readonly fillerSquares = viewChildren<ElementRef<HTMLDivElement>>('fillerSquare');
357358
protected readonly landmarkContainers = viewChildren<ElementRef<HTMLDivElement>>('landmarkContainer');
@@ -424,6 +425,13 @@ export class GameTabMap {
424425
});
425426
initAnimationWatcherEffect.destroy();
426427
});
428+
429+
effect(() => {
430+
// #142: the viewbox actually needs to be based on the victory location.
431+
const dashedPathSvg = this.dashedPathSvg().nativeElement;
432+
const victoryLocationYamlKey = this.#store.victoryLocationYamlKey();
433+
dashedPathSvg.setAttribute('viewBox', `0 0 300 ${VICTORY_LOCATION_CROP_LOOKUP[victoryLocationYamlKey].toString()}`);
434+
});
427435
}
428436

429437
protected togglePause() {

0 commit comments

Comments
 (0)