File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -248,8 +248,12 @@ function Carousel<T extends unknown = any>(
248248
249249 const offsetX = useDerivedValue ( ( ) => {
250250 const x = handlerOffsetX . value % computedAnimResult . TOTAL_WIDTH ;
251+
252+ if ( ! loop ) {
253+ return handlerOffsetX . value ;
254+ }
251255 return isNaN ( x ) ? 0 : x ;
252- } , [ computedAnimResult ] ) ;
256+ } , [ computedAnimResult , loop ] ) ;
253257
254258 useAnimatedReaction (
255259 ( ) => offsetX . value ,
@@ -323,14 +327,23 @@ function Carousel<T extends unknown = any>(
323327 }
324328
325329 const page = Math . round ( handlerOffsetX . value / width ) ;
330+
326331 const velocityPage = Math . round (
327332 ( handlerOffsetX . value + e . velocityX ) / width
328333 ) ;
329- const pageWithVelocity = Math . min (
334+
335+ let pageWithVelocity = Math . min (
330336 page + 1 ,
331337 Math . max ( page - 1 , velocityPage )
332338 ) ;
333339
340+ if ( ! loop ) {
341+ pageWithVelocity = Math . max (
342+ - ( data . length - 1 ) ,
343+ Math . min ( 0 , pageWithVelocity )
344+ ) ;
345+ }
346+
334347 if ( loop ) {
335348 handlerOffsetX . value = _withAnimationCallback (
336349 pageWithVelocity * width
Original file line number Diff line number Diff line change 1+ /**
2+ * In worklet
3+ * e.g. runOnJS(lop)(...);
4+ */
5+ export function log ( msg : any ) {
6+ console . log ( msg ) ;
7+ }
You can’t perform that action at this time.
0 commit comments