@yatoday/astro-ui 0.17.26 → 0.17.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -190,12 +190,15 @@ const { container: containerClass = '', swiper: swiperClass = '', swiperThumb: s
|
|
|
190
190
|
const thumbSwiperEl = document.getElementById(`swiper-thumb-${id}`);
|
|
191
191
|
if (!mainSwiperEl || !thumbSwiperEl) return;
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
// Wire up thumb hover + click → main slide navigation.
|
|
194
|
+
// Attach to light-DOM swiper-slide elements directly so this does not
|
|
195
|
+
// depend on the swiperafterinit lifecycle event (which can be flaky with
|
|
196
|
+
// dynamically registered swiper-element + init="false").
|
|
197
|
+
const thumbSlides = thumbSwiperEl.querySelectorAll('swiper-slide');
|
|
198
|
+
thumbSlides.forEach((slide, index) => {
|
|
199
|
+
const goTo = () => (mainSwiperEl as any)?.swiper?.slideTo(index);
|
|
200
|
+
slide.addEventListener('mouseenter', goTo);
|
|
201
|
+
slide.addEventListener('click', goTo);
|
|
199
202
|
});
|
|
200
203
|
|
|
201
204
|
// Thumb Slider navigation buttons
|
|
@@ -232,6 +235,23 @@ const { container: containerClass = '', swiper: swiperClass = '', swiperThumb: s
|
|
|
232
235
|
|
|
233
236
|
// Mark as initialized to show content and hide loader
|
|
234
237
|
elem.setAttribute('data-initialized', 'true');
|
|
238
|
+
|
|
239
|
+
// Force Swiper to re-measure once layout settles and again as images
|
|
240
|
+
// resolve. Without this, Swiper can measure slides while their
|
|
241
|
+
// <img> children still have no intrinsic size (loading="lazy" /
|
|
242
|
+
// cache-cold) and then lock itself via watchOverflow — silently
|
|
243
|
+
// swallowing every slideTo() and click handler on user machines
|
|
244
|
+
// where the images aren't already cached.
|
|
245
|
+
const scheduleUpdate = () => {
|
|
246
|
+
const s = (mainSwiperEl as any)?.swiper;
|
|
247
|
+
if (s && !s.destroyed) s.update();
|
|
248
|
+
};
|
|
249
|
+
requestAnimationFrame(scheduleUpdate);
|
|
250
|
+
mainSwiperEl.querySelectorAll('img').forEach((img) => {
|
|
251
|
+
if (img.complete && img.naturalWidth > 0) return;
|
|
252
|
+
img.addEventListener('load', scheduleUpdate, { once: true });
|
|
253
|
+
img.addEventListener('error', scheduleUpdate, { once: true });
|
|
254
|
+
});
|
|
235
255
|
});
|
|
236
256
|
};
|
|
237
257
|
|
|
@@ -32,12 +32,15 @@
|
|
|
32
32
|
const thumbSwiperEl = document.getElementById(`swiper-thumb-${id}`);
|
|
33
33
|
if (!mainSwiperEl || !thumbSwiperEl) return;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
// Wire up thumb hover + click → main slide navigation.
|
|
36
|
+
// Attach to light-DOM swiper-slide elements directly so this does not
|
|
37
|
+
// depend on the swiperafterinit lifecycle event (which can be flaky with
|
|
38
|
+
// dynamically registered swiper-element + init="false").
|
|
39
|
+
const thumbSlides = thumbSwiperEl.querySelectorAll('swiper-slide');
|
|
40
|
+
thumbSlides.forEach((slide, index) => {
|
|
41
|
+
const goTo = () => (mainSwiperEl as any)?.swiper?.slideTo(index);
|
|
42
|
+
slide.addEventListener('mouseenter', goTo);
|
|
43
|
+
slide.addEventListener('click', goTo);
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
// Thumb Slider navigation buttons
|
|
@@ -73,6 +76,23 @@
|
|
|
73
76
|
|
|
74
77
|
// Mark as initialized to show content and hide loader
|
|
75
78
|
elem.setAttribute('data-initialized', 'true');
|
|
79
|
+
|
|
80
|
+
// Force Swiper to re-measure once layout settles and again as images
|
|
81
|
+
// resolve. Without this, Swiper can measure slides while their
|
|
82
|
+
// <img> children still have no intrinsic size (loading="lazy" /
|
|
83
|
+
// cache-cold) and then lock itself via watchOverflow — silently
|
|
84
|
+
// swallowing every slideTo() and click handler on user machines
|
|
85
|
+
// where the images aren't already cached.
|
|
86
|
+
const scheduleUpdate = () => {
|
|
87
|
+
const s = (mainSwiperEl as any)?.swiper;
|
|
88
|
+
if (s && !s.destroyed) s.update();
|
|
89
|
+
};
|
|
90
|
+
requestAnimationFrame(scheduleUpdate);
|
|
91
|
+
mainSwiperEl.querySelectorAll('img').forEach((img) => {
|
|
92
|
+
if (img.complete && img.naturalWidth > 0) return;
|
|
93
|
+
img.addEventListener('load', scheduleUpdate, { once: true });
|
|
94
|
+
img.addEventListener('error', scheduleUpdate, { once: true });
|
|
95
|
+
});
|
|
76
96
|
};
|
|
77
97
|
|
|
78
98
|
init();
|