mirror of
https://github.com/zhigang1992/react-native-swiper.git
synced 2026-06-15 02:19:38 +08:00
63 lines
1.3 KiB
JavaScript
63 lines
1.3 KiB
JavaScript
var React = require('react-native')
|
|
var Swiper = require('./')
|
|
var {
|
|
StyleSheet,
|
|
Text,
|
|
View,
|
|
} = React
|
|
|
|
var styles = StyleSheet.create({
|
|
wrapper: {
|
|
},
|
|
slide1: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#9DD6EB',
|
|
},
|
|
slide2: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#97CAE5',
|
|
},
|
|
slide3: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#92BBD9',
|
|
},
|
|
text: {
|
|
color: '#fff',
|
|
fontSize: 30,
|
|
fontWeight: 'bold',
|
|
}
|
|
})
|
|
|
|
var swiper = React.createClass({
|
|
_onMomentumScrollEnd: function (e, state, context) {
|
|
// you can get `state` and `this`(ref to swiper's context) from params
|
|
console.log(state, context.state)
|
|
},
|
|
render: function() {
|
|
return (
|
|
<Swiper style={styles.wrapper}
|
|
onMomentumScrollEnd={this._onMomentumScrollEnd}
|
|
showsButtons={true}>
|
|
<View style={styles.slide1}>
|
|
<Text style={styles.text}>Hello Swiper</Text>
|
|
</View>
|
|
<View style={styles.slide2}>
|
|
<Text style={styles.text}>Beautiful</Text>
|
|
</View>
|
|
<View style={styles.slide3}>
|
|
<Text style={styles.text}>And simple</Text>
|
|
</View>
|
|
</Swiper>
|
|
)
|
|
}
|
|
})
|
|
|
|
module.exports = swiper
|
|
|