mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-05 06:18:12 +00:00
chore: thumbnail loading optimization
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
:key="i"
|
:key="i"
|
||||||
>
|
>
|
||||||
<div class="stock-text">
|
<div class="stock-text">
|
||||||
<p>{{ vehicleName.replace(/_/g, ' ') }}</p>
|
<div>{{ vehicleName.replace(/_/g, ' ') }}</div>
|
||||||
<small v-if="vehicleCargo">({{ vehicleCargo }})</small>
|
<small v-if="vehicleCargo">({{ vehicleCargo }})</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -189,20 +189,11 @@ ul > li > span {
|
|||||||
cursor: crosshair;
|
cursor: crosshair;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
|
||||||
max-height: 60px;
|
|
||||||
width: auto;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.traction-only {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stock-text {
|
.stock-text {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
margin-bottom: 0.25em;
|
margin-bottom: 0.25em;
|
||||||
|
padding: 0.25em 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vehicle-thumbnail">
|
<div class="vehicle-thumbnail" :data-load-status="imgStatus">
|
||||||
<img
|
<img
|
||||||
ref="imgRef"
|
ref="imgRef"
|
||||||
:src="`https://static.spythere.eu/thumbnails/v2/${imgName}.png`"
|
:src="`https://static.spythere.eu/thumbnails/v2/${imgName}.png`"
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
loading="lazy"
|
loading="lazy"
|
||||||
data-tooltip-type="VehiclePreviewTooltip"
|
data-tooltip-type="VehiclePreviewTooltip"
|
||||||
:data-tooltip-content="vehicleName"
|
:data-tooltip-content="vehicleName"
|
||||||
:data-load-status="imgStatus"
|
|
||||||
@error="onImageError"
|
@error="onImageError"
|
||||||
@load="onImageLoad"
|
@load="onImageLoad"
|
||||||
/>
|
/>
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, Ref, ref } from 'vue';
|
import { Ref, ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
vehicleName: { type: String, required: true },
|
vehicleName: { type: String, required: true },
|
||||||
@@ -29,8 +28,6 @@ const imgRef = ref(null) as Ref<HTMLElement | null>;
|
|||||||
const imgStatus = ref('loading');
|
const imgStatus = ref('loading');
|
||||||
|
|
||||||
function onImageError(event: Event) {
|
function onImageError(event: Event) {
|
||||||
console.log('error');
|
|
||||||
|
|
||||||
(event.target as HTMLImageElement).src = `/images/${props.fallbackName}.png`;
|
(event.target as HTMLImageElement).src = `/images/${props.fallbackName}.png`;
|
||||||
imgStatus.value = 'error';
|
imgStatus.value = 'error';
|
||||||
}
|
}
|
||||||
@@ -47,15 +44,15 @@ function onImageLoad() {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.vehicle-thumbnail {
|
.vehicle-thumbnail {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
&[data-load-status='loading'] {
|
||||||
|
min-height: 60px;
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 100ms ease-in-out;
|
transition: opacity 100ms ease-in-out;
|
||||||
|
|
||||||
&[data-load-status='loading'] {
|
|
||||||
min-height: 60px;
|
|
||||||
min-width: 150px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user