@yatoday/astro-ui 0.15.0 → 0.15.1
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.
|
@@ -149,14 +149,14 @@ const { container: containerClass = '', swiper: swiperClass = '', swiperThumb: s
|
|
|
149
149
|
<script>
|
|
150
150
|
import { on, get } from '../../utils';
|
|
151
151
|
|
|
152
|
-
import
|
|
153
|
-
|
|
154
|
-
register();
|
|
155
|
-
|
|
156
|
-
const init = () => {
|
|
152
|
+
// Dynamic import for better code splitting - loads Swiper only when needed
|
|
153
|
+
const init = async () => {
|
|
157
154
|
const matches = document.querySelectorAll('div[data-image-gallery-ikea]');
|
|
158
155
|
if (!matches.length) return;
|
|
159
156
|
|
|
157
|
+
const { register } = await import('swiper/element/bundle');
|
|
158
|
+
register();
|
|
159
|
+
|
|
160
160
|
matches.forEach((elem) => {
|
|
161
161
|
const id = (elem as HTMLElement).dataset.imageGalleryIkea || '0';
|
|
162
162
|
|
|
@@ -86,47 +86,57 @@ const {
|
|
|
86
86
|
|
|
87
87
|
<script>
|
|
88
88
|
import { addClasses, removeClasses } from '../../utils';
|
|
89
|
-
import { register } from 'swiper/element/bundle';
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
// Dynamic import for better code splitting - loads Swiper only when needed
|
|
91
|
+
async function initSwiper() {
|
|
92
|
+
const { register } = await import('swiper/element/bundle');
|
|
93
|
+
register();
|
|
92
94
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const matches = document.querySelectorAll('swiper-container');
|
|
96
|
+
if (matches && matches.length) {
|
|
97
|
+
matches.forEach((elem) => {
|
|
98
|
+
const id = elem.dataset.id;
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
100
|
+
if (id) {
|
|
101
|
+
elem.addEventListener(
|
|
102
|
+
'swiperreachend',
|
|
103
|
+
() => {
|
|
104
|
+
// Use requestAnimationFrame to batch DOM updates and prevent forced reflow
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
removeClasses(`#btn-next-${id}`, 'opacity-100');
|
|
107
|
+
addClasses(`#btn-next-${id}`, 'opacity-0');
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
false
|
|
111
|
+
);
|
|
112
|
+
elem.addEventListener(
|
|
113
|
+
'swiperreachbeginning',
|
|
114
|
+
() => {
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
addClasses(`#btn-prev-${id}`, 'opacity-0');
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
false
|
|
120
|
+
);
|
|
121
|
+
elem.addEventListener(
|
|
122
|
+
'swiperfromedge',
|
|
123
|
+
() => {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
removeClasses(`#btn-prev-${id}`, 'opacity-0');
|
|
126
|
+
addClasses(`#btn-next-${id}`, 'opacity-100');
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
false
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Initialize when DOM is ready
|
|
137
|
+
if (document.readyState === 'loading') {
|
|
138
|
+
document.addEventListener('DOMContentLoaded', initSwiper);
|
|
139
|
+
} else {
|
|
140
|
+
initSwiper();
|
|
131
141
|
}
|
|
132
142
|
</script>
|
|
@@ -201,6 +201,16 @@ const {
|
|
|
201
201
|
</WidgetWrapper>
|
|
202
202
|
|
|
203
203
|
<script>
|
|
204
|
-
import
|
|
205
|
-
|
|
204
|
+
// Dynamic import for better code splitting - loads Swiper only when needed
|
|
205
|
+
async function initSwiper() {
|
|
206
|
+
const { register } = await import('swiper/element/bundle');
|
|
207
|
+
register();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Initialize when DOM is ready
|
|
211
|
+
if (document.readyState === 'loading') {
|
|
212
|
+
document.addEventListener('DOMContentLoaded', initSwiper);
|
|
213
|
+
} else {
|
|
214
|
+
initSwiper();
|
|
215
|
+
}
|
|
206
216
|
</script>
|