|
137 | 137 | <div class="content">
|
138 | 138 | <img
|
139 | 139 | class="image"
|
140 |
| - :class="{ 'zoomed-in': zoomedIn }" |
141 |
| - :src=" |
142 |
| - expandedGalleryItem.raw_url |
143 |
| - ? expandedGalleryItem.raw_url |
144 |
| - : 'https://cdn.modrinth.com/placeholder-banner.svg' |
145 |
| - " |
146 |
| - :alt="expandedGalleryItem.title ? expandedGalleryItem.title : 'gallery-image'" |
| 140 | + :class="{ 'zoomed-in': zoomedIn, hidden: expandedGalleryImageLoading }" |
| 141 | + :src="expandedGalleryItem.raw_url || 'https://cdn.modrinth.com/placeholder-banner.svg'" |
| 142 | + :alt="expandedGalleryItem.title || 'gallery-image'" |
| 143 | + @load="expandedGalleryImageLoading = false" |
147 | 144 | @click.stop
|
148 | 145 | />
|
| 146 | + <img |
| 147 | + v-if="expandedGalleryImageLoading" |
| 148 | + class="image loading-image" |
| 149 | + :src="expandedGalleryItem.url || 'https://cdn.modrinth.com/placeholder-banner.svg'" |
| 150 | + :alt="expandedGalleryItem.title || 'gallery-image'" |
| 151 | + /> |
149 | 152 |
|
150 | 153 | <div class="floating" @click.stop>
|
151 | 154 | <div class="text">
|
|
165 | 168 | class="open circle-button"
|
166 | 169 | target="_blank"
|
167 | 170 | :href="
|
168 |
| - expandedGalleryItem.raw_url |
169 |
| - ? expandedGalleryItem.raw_url |
170 |
| - : 'https://cdn.modrinth.com/placeholder-banner.svg' |
| 171 | + expandedGalleryItem.raw_url || 'https://cdn.modrinth.com/placeholder-banner.svg' |
171 | 172 | "
|
172 | 173 | >
|
173 | 174 | <ExternalIcon aria-hidden="true" />
|
|
220 | 221 | <div v-for="(item, index) in project.gallery" :key="index" class="card gallery-item">
|
221 | 222 | <a class="gallery-thumbnail" @click="expandImage(item, index)">
|
222 | 223 | <img
|
223 |
| - :src="item.url ? item.url : 'https://cdn.modrinth.com/placeholder-banner.svg'" |
224 |
| - :alt="item.title ? item.title : 'gallery-image'" |
| 224 | + :src="item.url || 'https://cdn.modrinth.com/placeholder-banner.svg'" |
| 225 | + :alt="item.title || 'gallery-image'" |
225 | 226 | />
|
226 | 227 | </a>
|
227 | 228 | <div class="gallery-body">
|
@@ -339,6 +340,8 @@ export default defineNuxtComponent({
|
339 | 340 | return {
|
340 | 341 | expandedGalleryItem: null,
|
341 | 342 | expandedGalleryIndex: 0,
|
| 343 | + expandedGalleryImageLoading: false, |
| 344 | + expandedGalleryIndices: [], |
342 | 345 | zoomedIn: false,
|
343 | 346 |
|
344 | 347 | deleteIndex: -1,
|
@@ -381,18 +384,30 @@ export default defineNuxtComponent({
|
381 | 384 | this.expandedGalleryIndex = 0;
|
382 | 385 | }
|
383 | 386 | this.expandedGalleryItem = this.project.gallery[this.expandedGalleryIndex];
|
| 387 | + if (!this.expandedGalleryIndices.includes(this.expandedGalleryIndex)) { |
| 388 | + this.expandedGalleryImageLoading = true; |
| 389 | + this.expandedGalleryIndices.push(this.expandedGalleryIndex); |
| 390 | + } |
384 | 391 | },
|
385 | 392 | previousImage() {
|
386 | 393 | this.expandedGalleryIndex--;
|
387 | 394 | if (this.expandedGalleryIndex < 0) {
|
388 | 395 | this.expandedGalleryIndex = this.project.gallery.length - 1;
|
389 | 396 | }
|
390 | 397 | this.expandedGalleryItem = this.project.gallery[this.expandedGalleryIndex];
|
| 398 | + if (!this.expandedGalleryIndices.includes(this.expandedGalleryIndex)) { |
| 399 | + this.expandedGalleryImageLoading = true; |
| 400 | + this.expandedGalleryIndices.push(this.expandedGalleryIndex); |
| 401 | + } |
391 | 402 | },
|
392 | 403 | expandImage(item, index) {
|
393 | 404 | this.expandedGalleryItem = item;
|
394 | 405 | this.expandedGalleryIndex = index;
|
395 | 406 | this.zoomedIn = false;
|
| 407 | + if (!this.expandedGalleryIndices.includes(index)) { |
| 408 | + this.expandedGalleryImageLoading = true; |
| 409 | + this.expandedGalleryIndices.push(index); |
| 410 | + } |
396 | 411 | },
|
397 | 412 | resetEdit() {
|
398 | 413 | this.editIndex = -1;
|
@@ -604,12 +619,21 @@ export default defineNuxtComponent({
|
604 | 619 | max-height: calc(100vh - 2 * var(--spacing-card-lg));
|
605 | 620 | border-radius: var(--size-rounded-card);
|
606 | 621 |
|
| 622 | + &.loading-image { |
| 623 | + min-width: calc(60vw - 2 * var(--spacing-card-lg)); |
| 624 | + min-height: calc(60vh - 2 * var(--spacing-card-lg)); |
| 625 | + } |
| 626 | +
|
607 | 627 | &.zoomed-in {
|
608 | 628 | object-fit: cover;
|
609 | 629 | width: auto;
|
610 | 630 | height: calc(100vh - 2 * var(--spacing-card-lg));
|
611 | 631 | max-width: calc(100vw - 2 * var(--spacing-card-lg));
|
612 | 632 | }
|
| 633 | +
|
| 634 | + &.hidden { |
| 635 | + display: none; |
| 636 | + } |
613 | 637 | }
|
614 | 638 | .floating {
|
615 | 639 | position: absolute;
|
|
0 commit comments