Skip to content

Commit ee0f688

Browse files
committed
feat(InlineCitation): add loop mode support for circular scrolling
1 parent effb496 commit ee0f688

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

apps/www/content/3.components/1.chatbot/inline-citation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const props = defineProps<{
135135
</script>
136136
137137
<template>
138-
<Carousel :class="cn('w-full', props.class)">
138+
<Carousel :class="cn('w-full', props.class)" :opts="{ loop: true }">
139139
<slot />
140140
</Carousel>
141141
</template>

packages/elements/src/inline-citation/InlineCitationCarousel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const props = defineProps<{
99
</script>
1010

1111
<template>
12-
<Carousel :class="cn('w-full', props.class)">
12+
<Carousel :class="cn('w-full', props.class)" :opts="{ loop: true }">
1313
<slot />
1414
</Carousel>
1515
</template>

packages/shadcn-vue/components/ui/carousel/useCarousel.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Ref } from 'vue'
22
import type { UnwrapRefCarouselApi as CarouselApi, CarouselEmits, CarouselProps } from './interface'
33
import { createInjectionState } from '@vueuse/core'
44
import emblaCarouselVue from 'embla-carousel-vue'
5-
import { onMounted, ref } from 'vue'
5+
import { onMounted, ref, unref } from 'vue'
66

77
interface CarouselContext {
88
carouselRef: Ref<HTMLElement | undefined>
@@ -36,8 +36,14 @@ const [useProvideCarousel, useInjectCarousel] = createInjectionState(
3636
const canScrollPrev = ref(false)
3737

3838
function onSelect(api: CarouselApi) {
39-
canScrollNext.value = api?.canScrollNext() || false
40-
canScrollPrev.value = api?.canScrollPrev() || false
39+
if (unref(opts)?.loop) {
40+
canScrollNext.value = true
41+
canScrollPrev.value = true
42+
}
43+
else {
44+
canScrollNext.value = api?.canScrollNext() || false
45+
canScrollPrev.value = api?.canScrollPrev() || false
46+
}
4147
}
4248

4349
onMounted(() => {

0 commit comments

Comments
 (0)