10
10
<div class =" relative w-full overflow-hidden" >
11
11
<div class =" flex transition-transform duration-500 ease-in-out"
12
12
:style =" { transform: `translateX(-${release.currentImageIndex * 100}%)` }" >
13
- <img
14
- v-for =" (imgSrc, imgIndex) in release.image"
15
- :key =" imgIndex"
16
- :src =" imgSrc"
17
- class =" w-full object-cover aspect-square lg:h-screen"
18
- loading =" lazy"
19
- />
13
+ <img
14
+ v-for =" (imgSrc, imgIndex) in release.image"
15
+ :key =" imgIndex"
16
+ :src =" imgSrc"
17
+ :class =" { 'opacity-0': !release.imagesLoaded[imgIndex], 'opacity-100 transition-opacity duration-700': release.imagesLoaded[imgIndex] }"
18
+ @load =" release.imagesLoaded.splice(imgIndex, 1, true)"
19
+ class =" w-full object-cover aspect-square lg:h-screen"
20
+ loading =" lazy"
21
+ />
20
22
</div >
21
23
22
24
<!-- Navigation Controls -->
26
28
class =" absolute top-1/2 left-2 transform -translate-y-1/2 text-4xl lg:text-5xl text-gray-400 hover:scale-110 focus:outline-none animate-pulse"
27
29
aria-label =" Previous image"
28
30
>
29
- <
31
+ & #9664 ; <!-- Unicode for left arrow (◀) -->
30
32
</button >
31
33
<button
32
34
v-if =" release.image && release.image.length > 1"
33
35
@click =" nextImage(releaseIndex)"
34
36
class =" absolute top-1/2 right-2 transform -translate-y-1/2 text-4xl lg:text-5xl text-gray-400 hover:scale-110 focus:outline-none animate-pulse"
35
37
aria-label =" Next image"
36
38
>
37
- >
39
+ & #9654 ; <!-- Unicode for right arrow (▶) -- >
38
40
</button >
39
41
</div >
40
42
@@ -78,14 +80,13 @@ export default {
78
80
};
79
81
},
80
82
created () {
81
- // Fetch releases data on component creation
82
83
fetch (' /api/v1/releases' )
83
84
.then ((response ) => response .json ())
84
85
.then ((data ) => {
85
- // Initialize each release with a currentImageIndex
86
86
this .releases = data .map (release => ({
87
87
... release,
88
- currentImageIndex: 0 , // Start with the first image
88
+ currentImageIndex: 0 ,
89
+ imagesLoaded: Array (release .image .length ).fill (false ), // Track load state for each image
89
90
}));
90
91
})
91
92
.catch ((error ) => console .error (' Error fetching releases:' , error));
@@ -111,5 +112,4 @@ export default {
111
112
</script >
112
113
113
114
<style scoped>
114
- /* No additional custom styles required, as Tailwind classes handle the transition */
115
115
</style >
0 commit comments