Skip to content

Commit 5a63d08

Browse files
committed
Prevent LoadingImage from showing up when resizing window
1 parent 0653287 commit 5a63d08

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

client/src/components/LoadingImage.vue

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type {PropType} from "vue";
2+
import {onMounted, type PropType, ref} from "vue";
33
import type {Api} from "@shared/api";
44
import GTASAArtwork from "@/assets/images/gtasa-artwork.jpg";
55
import GTAIIIBG from "@/assets/images/iii-bg.png";
@@ -11,18 +11,31 @@ defineProps({
1111
}
1212
});
1313
14+
const loadingImageRef = ref<HTMLDivElement>();
15+
1416
const imageSrcs: Record<Api.GameKey, string> = {
1517
iii: GTAIIIBG,
1618
sa: GTASAArtwork,
1719
vc: ''
1820
}
1921
22+
onMounted(() => {
23+
if (loadingImageRef.value === undefined) {
24+
console.error('Cannot find loading image element');
25+
return;
26+
}
27+
28+
const loadingImageEl = loadingImageRef.value
29+
30+
document.addEventListener('click', () => {
31+
loadingImageEl.classList.remove('loading-image--active');
32+
});
33+
})
34+
2035
</script>
2136

2237
<template>
23-
<div class="loading-image loading-image--active" :class="`loading-image--${game}`" @click="(e) => {
24-
(e.currentTarget as HTMLDivElement).classList.remove('loading-image--active');
25-
}">
38+
<div ref="loadingImageRef" class="loading-image loading-image--active" :class="`loading-image--${game}`">
2639
<img :src="imageSrcs[game]" alt="Game background">
2740
<span>Click to continue</span>
2841
</div>

0 commit comments

Comments
 (0)