Skip to content

Commit

Permalink
fix(initial): add firstItem prop to carousel, remove dirty-workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
JonatanSalas committed Oct 27, 2020
1 parent 87a233c commit 66c77ad
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/components/StoryDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dimensions, Platform } from 'react-native';
import { Overlay } from 'react-native-elements';
import React, { useEffect, useRef } from 'react';
import React, { useRef } from 'react';
import Carousel from 'react-native-snap-carousel';

import {
Expand Down Expand Up @@ -80,23 +80,6 @@ export const StoryDetail: React.FC<StoreDetailProps> = ({
}) => {
const carouselRef: any = useRef(null);

useEffect(() => {
let timeoutId: any = null;

if (initial !== null) {
timeoutId = setTimeout(
() => carouselRef.current.snapToItem(initial, true, true),
Platform.OS === 'ios' ? 25 : 0
);
}

return () => {
if (timeoutId !== null) {
clearTimeout(timeoutId);
}
};
}, [initial]);

return (
<Overlay
fullScreen
Expand All @@ -109,6 +92,7 @@ export const StoryDetail: React.FC<StoreDetailProps> = ({
ref={carouselRef}
itemWidth={width}
sliderWidth={width}
firstItem={initial}
initialScrollIndex={initial}
scrollInterpolator={instaEffect.scrollInterpolator}
slideInterpolatedStyle={instaEffect.animatedStyles}
Expand Down

0 comments on commit 66c77ad

Please sign in to comment.