pavelbabenko / react-native-awesome-gallery

Performant, native-like, and well-customizable gallery for React Native.
MIT License
498 stars 54 forks source link

fix: ScrollX when there's only one picture #23

Closed alantoa closed 3 years ago

alantoa commented 3 years ago

fix: When I only have one picture , scroll horizontal picture is hidden. I fix it. Watch the Bug Demo

pavelbabenko commented 3 years ago

Hi @MonsterAnan Thank you for the pull request Could you write which props are you using and what is the data.length so I can reproduce the bug?

alantoa commented 3 years ago

thank you reply. Is this,I copy you project demo. this is Photos Screen params:

...
 const { params } = useRoute<RouteProp<RootParamList, "photos">>() 
 // params = {"images": ["https://upload.42how.com/article/weibo_1627448462288.jpg"], "index": 0}
...
  return (
    <View style={styles.container}>
      <AwesomeGallery
        data={params?.images.map((uri) => ({ uri }))}
        keyExtractor={(item) => item.uri}
        renderItem={renderItem}
        initialIndex={params.index}
        onIndexChange={onIndexChange}
        onSwipeToClose={goBack}
      />
    </View>
  )

After that, it'll be just like yours code.

pavelbabenko commented 3 years ago

Fixed in v0.2.1

alantoa commented 3 years ago

ok, thank you