@@ -118,7 +118,7 @@ export interface CarouselEmits {
118
118
import { computed , ref , watch , onMounted } from ' vue'
119
119
import useEmblaCarousel from ' embla-carousel-vue'
120
120
import { Primitive , useForwardProps } from ' reka-ui'
121
- import { reactivePick , computedAsync } from ' @vueuse/core'
121
+ import { reactivePick } from ' @vueuse/core'
122
122
import { useAppConfig } from ' #imports'
123
123
import { useLocale } from ' ../composables/useLocale'
124
124
import { tv } from ' ../utils/tv'
@@ -175,41 +175,45 @@ const options = computed<EmblaOptionsType>(() => ({
175
175
direction: dir .value === ' rtl' ? ' rtl' : ' ltr'
176
176
}))
177
177
178
- const plugins = computedAsync <EmblaPluginType []>(async () => {
179
- const plugins = []
178
+ const plugins = ref <EmblaPluginType []>([])
179
+
180
+ async function loadPlugins() {
181
+ const emblaPlugins: EmblaPluginType [] = []
180
182
181
183
if (props .autoplay ) {
182
184
const AutoplayPlugin = await import (' embla-carousel-autoplay' ).then (r => r .default )
183
- plugins .push (AutoplayPlugin (typeof props .autoplay === ' boolean' ? {} : props .autoplay ))
185
+ emblaPlugins .push (AutoplayPlugin (typeof props .autoplay === ' boolean' ? {} : props .autoplay ))
184
186
}
185
187
186
188
if (props .autoScroll ) {
187
189
const AutoScrollPlugin = await import (' embla-carousel-auto-scroll' ).then (r => r .default )
188
- plugins .push (AutoScrollPlugin (typeof props .autoScroll === ' boolean' ? {} : props .autoScroll ))
190
+ emblaPlugins .push (AutoScrollPlugin (typeof props .autoScroll === ' boolean' ? {} : props .autoScroll ))
189
191
}
190
192
191
193
if (props .autoHeight ) {
192
194
const AutoHeightPlugin = await import (' embla-carousel-auto-height' ).then (r => r .default )
193
- plugins .push (AutoHeightPlugin (typeof props .autoHeight === ' boolean' ? {} : props .autoHeight ))
195
+ emblaPlugins .push (AutoHeightPlugin (typeof props .autoHeight === ' boolean' ? {} : props .autoHeight ))
194
196
}
195
197
196
198
if (props .classNames ) {
197
199
const ClassNamesPlugin = await import (' embla-carousel-class-names' ).then (r => r .default )
198
- plugins .push (ClassNamesPlugin (typeof props .classNames === ' boolean' ? {} : props .classNames ))
200
+ emblaPlugins .push (ClassNamesPlugin (typeof props .classNames === ' boolean' ? {} : props .classNames ))
199
201
}
200
202
201
203
if (props .fade ) {
202
204
const FadePlugin = await import (' embla-carousel-fade' ).then (r => r .default )
203
- plugins .push (FadePlugin (typeof props .fade === ' boolean' ? {} : props .fade ))
205
+ emblaPlugins .push (FadePlugin (typeof props .fade === ' boolean' ? {} : props .fade ))
204
206
}
205
207
206
208
if (props .wheelGestures ) {
207
209
const { WheelGesturesPlugin } = await import (' embla-carousel-wheel-gestures' )
208
- plugins .push (WheelGesturesPlugin (typeof props .wheelGestures === ' boolean' ? {} : props .wheelGestures ))
210
+ emblaPlugins .push (WheelGesturesPlugin (typeof props .wheelGestures === ' boolean' ? {} : props .wheelGestures ))
209
211
}
210
212
211
- return plugins
212
- })
213
+ plugins .value = emblaPlugins
214
+ }
215
+
216
+ watch (() => [props .autoplay , props .autoScroll , props .autoHeight , props .classNames , props .fade , props .wheelGestures ], loadPlugins , { immediate: true })
213
217
214
218
const [emblaRef, emblaApi] = useEmblaCarousel (options .value , plugins .value )
215
219
0 commit comments