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

initialPage not working (android) #967

Open
thiagomachado1998 opened this issue Feb 3, 2025 · 1 comment
Open

initialPage not working (android) #967

thiagomachado1998 opened this issue Feb 3, 2025 · 1 comment

Comments

@thiagomachado1998
Copy link

thiagomachado1998 commented Feb 3, 2025

Environment

react native 0.76.5

Description

I've tested most of the latest versions of the library, but none of them have this feature working.

`<PagerView
style={{ flex: 1 }}
initialPage={indexImagem.current}
>
{imagens.map((item, index) =>
(<View style={{ flex: 1, backgroundColor: 'black' }} key={index}>

                <View style={[StyleSheet.absoluteFill, { flex: 1 }]}>
                <FastImage
                style={[StyleSheet.absoluteFill, { flex: 1 }]}
                source={{
                    uri: item.imagePath,
                    headers: { Authorization: 'someAuthToken' },
                    priority: FastImage.priority.high,
                }}
                resizeMode={FastImage.resizeMode.contain}
                /> 
                </View>

                <View
                  style={{
                    width: '100%',
                    flexDirection: 'row',
                    justifyContent: 'space-between',
                    backgroundColor: 'transparent',
                    padding: 10,
                  }}
                >
                  <TouchableOpacity
                    onPress={() => [
                      setModalGaleria(false)
                    ]}
                  >
                    <Text
                      style={{
                        backgroundColor: 'white',
                        paddingLeft: 15,
                        paddingRight: 15,
                        paddingTop: 5,
                        paddingBottom: 5,
                        borderRadius: 50,
                        fontSize: alturaDaTela * 0.015,
                        color: '#121212',
                      }}
                    >
                      Sair
                    </Text>
                  </TouchableOpacity>
                  <TouchableOpacity >
                    <Icon
                      style={{ padding: 5 }}
                      name="trash-outline"
                      size={alturaDaTela * 0.024}
                      color="white"
                    />
                  </TouchableOpacity>
                </View>
                      </View>
                    )
                  )}
                </PagerView>`
@thiagomachado1998 thiagomachado1998 changed the title initialPage not working initialPage not working (android) Feb 3, 2025
@rossicler-hostalky
Copy link

Same here, initial page is not working on Android, the only way I could make it work is to use setPageWithoutAnimation after first render is done. It also only worked if I wrap it with setTimeout, like setTimeout(() => ref.current?.setPageWithoutAnimation(currentIndex), 0);.

This is not ideal at all, as the user can see the page changing.

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

2 participants