React-native-swiper: Horizontal={false} not working in Android.

Created on 15 Jun 2017  路  10Comments  路  Source: leecade/react-native-swiper

This moves the dots to the right, but swiping is still left to right.

help wanted

Most helpful comment


    let containerStyle = {};
    let pageStyle = {};

    if (Platform.OS == 'android') {
      let offset = ((height - StatusBar.currentHeight) - width) / 2;
      containerStyle.transform = [{rotate: "90deg"}];
      containerStyle.width = height - StatusBar.currentHeight;
      containerStyle.height = width;
      containerStyle.top = offset;
      containerStyle.left = offset * -1;

      pageStyle.transform = [{rotate: "-90deg"}];
      pageStyle.width = width;
      pageStyle.height = height - StatusBar.currentHeight;
      pageStyle.top = offset * -1;  //left
      pageStyle.right = offset  * -1;   //top
    } else {
      containerStyle.flex = 1;
      pageStyle.flex = 1;
    }


<View style={containerStyle}>
        <Swiper
          loop={false}
          showsButtons={false}
          showsPagination={false}
          horizontal={Platform.OS == 'android'}
          width={Platform.OS == 'android' ? height : width}
          height={Platform.OS == 'android' ? width : height}
        >
          <Page1 style={[{backgroundColor: '#9297A1'}, pageStyle]}/>
          <Page2 style={[{backgroundColor: '#9297A1'}, pageStyle]}/>
        </Swiper>
</View>

Hope this help

All 10 comments


    let containerStyle = {};
    let pageStyle = {};

    if (Platform.OS == 'android') {
      let offset = ((height - StatusBar.currentHeight) - width) / 2;
      containerStyle.transform = [{rotate: "90deg"}];
      containerStyle.width = height - StatusBar.currentHeight;
      containerStyle.height = width;
      containerStyle.top = offset;
      containerStyle.left = offset * -1;

      pageStyle.transform = [{rotate: "-90deg"}];
      pageStyle.width = width;
      pageStyle.height = height - StatusBar.currentHeight;
      pageStyle.top = offset * -1;  //left
      pageStyle.right = offset  * -1;   //top
    } else {
      containerStyle.flex = 1;
      pageStyle.flex = 1;
    }


<View style={containerStyle}>
        <Swiper
          loop={false}
          showsButtons={false}
          showsPagination={false}
          horizontal={Platform.OS == 'android'}
          width={Platform.OS == 'android' ? height : width}
          height={Platform.OS == 'android' ? width : height}
        >
          <Page1 style={[{backgroundColor: '#9297A1'}, pageStyle]}/>
          <Page2 style={[{backgroundColor: '#9297A1'}, pageStyle]}/>
        </Swiper>
</View>

Hope this help

+1

+1

+1

@leecade Would you consider a PR changing the implementation to using Animated and a over-sized fixed position container that can be animated to slide. You wouldn't lose any features and it would support Android and iOS exactly the same without any device-specific features.

+1 , so this problem is still not solved?

dup #174 , #199
+1 It seems hard work but worth it!

see #595 and my fix (apart from bullets not showing correct index)
pull req. https://github.com/leecade/react-native-swiper/pull/643

+1

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndrewSouthpaw picture AndrewSouthpaw  路  3Comments

gwhite-dayspring picture gwhite-dayspring  路  3Comments

itinance picture itinance  路  3Comments

JonasOmdal picture JonasOmdal  路  3Comments

chetanparakh picture chetanparakh  路  3Comments