@@ -163,6 +163,22 @@ const rootProps = useForwardProps(reactivePick(props, 'active', 'align', 'breakp
163163const prevIcon = computed (() => props .prevIcon || (dir .value === ' rtl' ? appConfig .ui .icons .arrowRight : appConfig .ui .icons .arrowLeft ))
164164const nextIcon = computed (() => props .nextIcon || (dir .value === ' rtl' ? appConfig .ui .icons .arrowLeft : appConfig .ui .icons .arrowRight ))
165165
166+ const stopAutoplayOnInteraction = computed (() => {
167+ if (typeof props .autoplay === ' boolean' ) {
168+ return true
169+ }
170+
171+ return props .autoplay .stopOnInteraction ?? true
172+ })
173+
174+ const stopAutoScrollOnInteraction = computed (() => {
175+ if (typeof props .autoScroll === ' boolean' ) {
176+ return true
177+ }
178+
179+ return props .autoScroll .stopOnInteraction ?? true
180+ })
181+
166182const ui = computed (() => tv ({ extend: tv (theme ), ... (appConfig .ui ?.carousel || {}) })({
167183 orientation: props .orientation
168184}))
@@ -223,20 +239,26 @@ watch(options, () => {
223239 emblaApi .value ?.reInit (options .value , plugins .value )
224240}, { flush: ' post' })
225241
226- function scrollPrev() {
227- emblaApi .value ?.scrollPrev ()
228-
229- if (props .autoplay && (typeof props .autoplay === ' boolean' || props .autoplay .stopOnInteraction !== false )) {
242+ function stopOnInteraction() {
243+ if (stopAutoplayOnInteraction .value ) {
230244 emblaApi .value ?.plugins ().autoplay ?.stop ()
231245 }
246+
247+ if (stopAutoScrollOnInteraction .value ) {
248+ emblaApi .value ?.plugins ().autoScroll ?.stop ()
249+ }
250+ }
251+
252+ function scrollPrev() {
253+ emblaApi .value ?.scrollPrev ()
254+ stopOnInteraction ()
232255}
256+
233257function scrollNext() {
234258 emblaApi .value ?.scrollNext ()
235-
236- if (props .autoplay && (typeof props .autoplay === ' boolean' || props .autoplay .stopOnInteraction !== false )) {
237- emblaApi .value ?.plugins ().autoplay ?.stop ()
238- }
259+ stopOnInteraction ()
239260}
261+
240262function scrollTo(index : number ) {
241263 emblaApi .value ?.scrollTo (index )
242264}
0 commit comments