diff --git a/src/Carousel.tsx b/src/Carousel.tsx index 32e87e40..fee411e5 100644 --- a/src/Carousel.tsx +++ b/src/Carousel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Animated, { runOnJS, useDerivedValue } from 'react-native-reanimated'; +import { runOnJS, useDerivedValue } from 'react-native-reanimated'; import { useCarouselController } from './hooks/useCarouselController'; import { useAutoPlay } from './hooks/useAutoPlay'; @@ -8,7 +8,7 @@ import { ScrollViewGesture } from './ScrollViewGesture'; import { useVisibleRanges } from './hooks/useVisibleRanges'; import type { ICarouselInstance, TCarouselProps } from './types'; -import { StyleSheet, View } from 'react-native'; +import { StyleSheet } from 'react-native'; import { BaseLayout } from './layouts/BaseLayout'; import { useLayoutConfig } from './hooks/useLayoutConfig'; import { useInitProps } from './hooks/useInitProps'; @@ -198,40 +198,29 @@ const Carousel = React.forwardRef>( return ( - - - - {data.map(renderLayout)} - - - + {data.map(renderLayout)} + ); } diff --git a/src/ScrollViewGesture.tsx b/src/ScrollViewGesture.tsx index dfceabe3..2c9db11e 100644 --- a/src/ScrollViewGesture.tsx +++ b/src/ScrollViewGesture.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleProp, StyleSheet, ViewStyle } from 'react-native'; +import type { StyleProp, ViewStyle } from 'react-native'; import { PanGestureHandler, PanGestureHandlerGestureEvent, @@ -27,11 +27,12 @@ type GestureContext = { interface Props { size: number; infinite?: boolean; + testID?: string; + style?: StyleProp; onScrollBegin?: () => void; onScrollEnd?: () => void; onTouchBegin?: () => void; onTouchEnd?: () => void; - style?: StyleProp; translation: Animated.SharedValue; } @@ -51,8 +52,10 @@ const IScrollViewGesture: React.FC = (props) => { } = React.useContext(CTX); const { - translation, size, + translation, + testID, + style = {}, onScrollBegin, onScrollEnd, onTouchBegin, @@ -269,42 +272,22 @@ const IScrollViewGesture: React.FC = (props) => { ] ); - const directionStyle = React.useMemo(() => { - return vertical ? styles.contentHorizontal : styles.contentVertical; - }, [vertical]); - return ( - - {props.children} - - + + ); }; export const ScrollViewGesture = IScrollViewGesture; - -const styles = StyleSheet.create({ - container: { - flex: 1, - overflow: 'hidden', - }, - contentVertical: { - flexDirection: 'column', - }, - contentHorizontal: { - flexDirection: 'row', - }, -});