File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,15 @@ export const Carousel = defineComponent({
141
141
} )
142
142
143
143
Object . assign ( config , fallbackConfig . value , newConfig )
144
+
145
+ // Validate itemsToShow
146
+ if ( ! isAuto . value ) {
147
+ config . itemsToShow = getNumberInRange ( {
148
+ val : Number ( config . itemsToShow ) ,
149
+ max : props . clamp ? slidesCount . value : Infinity ,
150
+ min : 1 ,
151
+ } ) ;
152
+ }
144
153
}
145
154
146
155
const handleResize = throttle ( ( ) => {
@@ -209,11 +218,6 @@ export const Carousel = defineComponent({
209
218
min : minSlideIndex . value ,
210
219
} )
211
220
}
212
-
213
- // Validate itemsToShow
214
- if ( ! isAuto . value ) {
215
- config . itemsToShow = Math . max ( Number ( config . itemsToShow ) , 1 ) ;
216
- }
217
221
}
218
222
219
223
const ignoreAnimations = computed < false | string [ ] > ( ( ) => {
@@ -848,7 +852,7 @@ export const Carousel = defineComponent({
848
852
slidesCount,
849
853
} )
850
854
851
- expose < CarouselExposed > ( {
855
+ expose < CarouselExposed > ( reactive ( {
852
856
data,
853
857
next,
854
858
prev,
@@ -858,7 +862,7 @@ export const Carousel = defineComponent({
858
862
updateSlideSize,
859
863
updateSlidesData,
860
864
...toRefs ( provided ) ,
861
- } )
865
+ } ) )
862
866
863
867
return ( ) => {
864
868
const slotSlides = slots . default || slots . slides
Original file line number Diff line number Diff line change @@ -150,4 +150,7 @@ export const carouselProps = {
150
150
default : DEFAULT_CONFIG . wrapAround ,
151
151
type : Boolean ,
152
152
} ,
153
+ clamp : {
154
+ type : Boolean ,
155
+ }
153
156
}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export type CarouselConfig = {
49
49
touchDrag ?: boolean
50
50
transition ?: number
51
51
wrapAround ?: boolean
52
+ clamp ?: boolean
52
53
}
53
54
54
55
export type VueClass = string | Record < string , boolean > | VueClass [ ]
You can’t perform that action at this time.
0 commit comments