1.0.1 • Published 5 years ago

rnezswiper v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

RN-Swiper

ScreenShot

image

or project/screenshot.gif

Usage

yarn add rnezswiper or npm install rnezswiper

import RNSwiper from 'rnezswiper'

let data = 'HelloWord'.toUpperCase().split('')
const { width, height } = Dimensions.get("window")

<View style={styles.container}>
    <View style={{ height: 200 }}> // wrapStyle
        <RNSwiper
        loop
        autoPlay
        initIndex={0}
        onChangeIndex={(index) => {  }}
        slideStyle={styles.slideStyle}
        renderPagination={(index) => { // customize pagination
            return (
            <View style={[{ position: 'absolute', bottom: 0, height: 30, width, left: 0,zIndex: 1 }]}>
                <Text style={{ color: '#fff',textAlign: 'center' }}>{`${index + 1}/${data.length}`}</Text>
            </View>
            )
        }}
        >
        {
            data.map(item => <Text key={item} style={styles.font}>{item}</Text>)
        }
        </RNSwiper>
    </View>
    <Text>other content</Text>
</View>

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  font: {
    color: '#fff',
    fontSize: 30
  },
  slideStyle: { height: 200, width, backgroundColor: '#7e57c2' },
});

Properties

PropDefaultTypeDescription
slideStyle{}ViewStylenone
looptruebooleanSet to false to disable continuous loop mode.
autoPlaytruebooleanSet to true enable auto play mode.
autoPlayTimeOut3000numberauto paly delay
initIndex0numberIndex number of initial slide
onIndexChanged(index) => nullfunctionCalled with the new index when the user swiped
renderPagination(index) => nullJSXcustomize pagination
animation(value, toValue) => Animatedfunctioncustomize animated