React-native-swiper: Swipe gesture is not detected on iOS when setting a fixed width for the Swiper, works fine on android.

Created on 7 Feb 2018  路  16Comments  路  Source: leecade/react-native-swiper

Which OS ?

iOS

Version

Which versions are you using:

  • react-native-swiper v1.5.13
  • react-native v0.52.0

Expected behaviour

I expect the swipe gesture on the swiper to be picked up and executed correctly

Actual behaviour

Nothing happens.
I think you should be throwing some type of error if this is actually a system breaking thing to do or at least mention it in your Documentation.

Steps to reproduce

  1. Create a Swiper
  2. Give it a style prop
  3. Give it a fixed width via StyleSheet.create()

Most helpful comment

@MariusMeiners I just ran into this same issue. Change the 'style' prop to 'containerStyle' and reload.

All 16 comments

@MariusMeiners I just ran into this same issue. Change the 'style' prop to 'containerStyle' and reload.

Me also, IOS gesture not work, and the slide show only the first one ( Android working fine )

@mysport12 I've already used a different workaround, thanks tho ! :) i just wanted to make other people aware of the issue because it took me forever to figure out why it wasnt working....

@MariusMeiners , do you use different library?

@Theng no i just changed my layout to work with flex values instead of width then the swiper worked as expected

@MariusMeiners I also use flex, but on iOS show only first slide "Slide 1" and I can't swipe it also, do you have any suggestion to me.

<Swiper style={{ flex: 1 }} showsButtons={true}>
    <View style={styles.viewFlex}>
                    <Text>Slide 1</Text>
    </View>
    <View style={styles.viewFlex}>
                    <Text>Slide 2</Text>
    </View>
    <View style={styles.viewFlex}>
                    <Text>Slide 3</Text>
    </View>
</Swiper>
const styles = {
    viewFlex: {
        flex:1,
        justifyContent: "center",
        alignItems: "center"
    }
};

me too .

Adding containerStyle to <Swiper> worked for me as per @mysport12

Sample:

import { Dimensions } from 'react-native';
...
const deviceWidth = Dimensions.get('window').width;
<Swiper containerStyle={{ width: deviceWidth }}>

Im going to close this issue as the workaround from @mysport12 seems to be the only solution we will have going forward. I dont think any maintainer is interested in fixing this correctly.

Should be re open.
The gestures just no work in iOS.
I tried every suggestion but only works in Android.

@MariusMeiners I just ran into this same issue. Change the 'style' prop to 'containerStyle' and reload.

That's worked for me.Tnx

@AugustusCosta if you want to reopen the issue you should show your exact problem otherwise it wont be reproducable for the maintainer...

In my case, removing flex: 1 from style of <Swiper> solved the issue.

I have this same issue. Change the 'style' prop to 'containerStyle' and work for me . Thanks

I have this same issue. Change the 'style' prop to 'containerStyle' and work for me . Thanks

thanks... It is also working on my side.

Thanks - everything started working when I changed style to containerStyle - I was even blaming React Navigation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agzuniverse picture agzuniverse  路  3Comments

chetanparakh picture chetanparakh  路  3Comments

nomoreboredom picture nomoreboredom  路  3Comments

nicolabortignon picture nicolabortignon  路  3Comments

Liqiankun picture Liqiankun  路  3Comments