Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second image not loading right away #184

Open
jcoulaud opened this issue Mar 1, 2023 · 0 comments
Open

Second image not loading right away #184

jcoulaud opened this issue Mar 1, 2023 · 0 comments

Comments

@jcoulaud
Copy link

jcoulaud commented Mar 1, 2023

Hi,

If I open an image and slide to the left or right, the following image does not load immediately.
I have to go back and slide it again, as you can see in the video. Would you happen to know why?

Here is my code:

export const Gallery = ({ images }: Props) => {
  // variables
  const [isGalleryVisible, setIsGalleryVisible] = useState<boolean>(false);
  const [currentImageIndex, setImageIndex] = useState<number>(0);

  // functions
  const onShowGallery = (index: number) => {
    setImageIndex(index);
    setIsGalleryVisible(true);
  };

  const onHideGallery = () => setIsGalleryVisible(false);

  // renders
  const renderImage = ({ item, index }: { item: Image | string; index: number }) => {
    return (
      <ImageContainer onPress={() => onShowGallery(index)}>
        <CustomImage uri={item.url} height={index > 0 ? THUMBNAIL_SIZE : 0} />
        <IconContainer>
          <CustomIcon name="expand" type="lined" fill={colors.white} width={16} />
        </IconContainer>
      </ImageContainer>
    );
  };

  return (
    <Container>
      <FlatList
        data={gif ? images : images.slice(1)}
        renderItem={({ item, index }) => renderImage({ item, index: index + 1 })}
        horizontal
      />

      <ImageView
        images={images}
        imageIndex={currentImageIndex}
        visible={isGalleryVisible}
        onRequestClose={onHideGallery}
        backgroundColor={colors.primaryReverse}
        presentationStyle="overFullScreen"
      />
    </Container>
  );
};
CleanShot.2023-03-01.at.20.33.21.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant