@@ -173,7 +173,7 @@ const CarouselMomentum = <Item,>(
173173 : event . contentOffset . y ; // Get the horizontal scroll offset
174174 scrollX . set ( offsetX ) ; // Update the scroll position for animations
175175 const nextIndex = Math . round (
176- offsetX / ( ! vertical ? itemWidth : itemHeight )
176+ offsetX / ( ! vertical ? itemWidth ! : itemHeight ! )
177177 ) ; // Calculate the current index
178178 // If the index changes, call the onSnap callback
179179 if ( nextIndex !== currentIndex ) {
@@ -190,8 +190,8 @@ const CarouselMomentum = <Item,>(
190190 * This is used when we want to programmatically scroll to a specific item.
191191 */
192192 const calculateItemOffsetStatic = useCallback (
193- ( index : number ) => index * ( ! vertical ? itemWidth : itemHeight ) ,
194- [ itemWidth , itemHeight ]
193+ ( index : number ) => index * ( ! vertical ? itemWidth ! : itemHeight ! ) ,
194+ [ vertical , itemWidth , itemHeight ]
195195 ) ;
196196
197197 /**
@@ -322,11 +322,11 @@ const CarouselMomentum = <Item,>(
322322 itemStyle = { itemStyle }
323323 renderItem = { renderItem }
324324 info = { info }
325- itemWidth = { itemWidth }
325+ itemWidth = { itemWidth ! }
326326 inactiveScale = { inactiveScale }
327327 scrollX = { scrollX }
328328 animation = { animation }
329- itemHeight = { itemHeight }
329+ itemHeight = { itemHeight ! }
330330 vertical = { vertical }
331331 customAnimation = { customAnimation }
332332 />
@@ -373,10 +373,10 @@ const CarouselMomentum = <Item,>(
373373 contentContainerStyle = {
374374 ! vertical
375375 ? {
376- paddingHorizontal : ( sliderWidth - itemWidth ) / 2 , // Center the items within the container
376+ paddingHorizontal : ( sliderWidth ! - itemWidth ! ) / 2 , // Center the items within the container
377377 }
378378 : {
379- paddingVertical : ( sliderHeight - itemHeight ) / 2 ,
379+ paddingVertical : ( sliderHeight ! - itemHeight ! ) / 2 ,
380380 }
381381 }
382382 showsVerticalScrollIndicator = { false }
0 commit comments