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