Skip to content

Commit

Permalink
fix: issues with carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Meissonnier committed Sep 11, 2024
1 parent bded490 commit 83a7fff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export const VideoCarouselModule: FunctionComponent<VideoCarouselModuleBaseProps
testID="videoCarousel"
vertical={false}
height={CAROUSEL_HEIGHT}
panGestureHandlerProps={{ activeOffsetX: [-5, 5] }}
onConfigurePanGesture={(gestureChain) => {
gestureChain.activeOffsetX([-5, 5])
}}
width={windowWidth}
loop={false}
scrollAnimationDuration={CAROUSEL_ANIMATION_DURATION}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const OfferPreviewModal = ({
onClose,
isVisible = false,
}: OfferPreviewModalProps) => {
const [carouselSize, setCarouselSize] = useState({ width: 100, height: 100 })
const [carouselSize, setCarouselSize] = useState<{ width: number; height: number }>()
const carouselRef = useRef<ICarouselInstance>(null)
const progressValue = useSharedValue<number>(0)
const { width: windowWidth, height: windowHeight } = useWindowDimensions()
Expand Down Expand Up @@ -69,25 +69,27 @@ export const OfferPreviewModal = ({
accessibilityLabel="Image précédente"
/>

<Carousel
ref={carouselRef}
testID="offerImageContainerCarousel"
vertical={false}
width={carouselSize.width}
height={carouselSize.height}
loop={false}
defaultIndex={defaultIndex}
enabled={false}
scrollAnimationDuration={500}
onProgressChange={(_, absoluteProgress) => {
progressValue.value = absoluteProgress
setTitle(getTitleLabel(absoluteProgress))
}}
data={offerImages}
renderItem={({ item: image, index }) => (
<CarouselImage source={{ uri: image }} accessibilityLabel={`Image ${index + 1}`} />
)}
/>
{carouselSize ? (
<Carousel
ref={carouselRef}
testID="offerImageContainerCarousel"
vertical={false}
width={carouselSize.width}
height={carouselSize.height}
loop={false}
defaultIndex={defaultIndex}
enabled={false}
scrollAnimationDuration={500}
onProgressChange={(_, absoluteProgress) => {
progressValue.value = absoluteProgress
setTitle(getTitleLabel(absoluteProgress))
}}
data={offerImages}
renderItem={({ item: image, index }) => (
<CarouselImage source={{ uri: image }} accessibilityLabel={`Image ${index + 1}`} />
)}
/>
) : null}

<RoundedButton
iconName="next"
Expand Down

0 comments on commit 83a7fff

Please sign in to comment.