react native图片轮播组件

在github上找了一个react-native-image-slider, 地址:
https://github.com/PaulBGD/react-native-image-slider.git

按照教程使用后,发现无法进行图片之间的切换
研究源代码,使用的是ScrollView, 在ScrollView上使用PanResponder获取触摸事件,经调试发现不能获取到
然后怎么弄也没有弄出来,干脆就自己写一个。

图片轮播组件

原理:

  • 使用基础View,根据图片数量设置宽度
  • 使用PanResponder作为触摸,根据触摸事件拖动View的位置
  • 根据时间/滑动距离来判断是否切换下一张
  • 使用Animated来做动画

源代码地址:

https://github.com/gehaiqing/react-native-image-slider

本文地址: http://gehaiqing.com/2016/11/07/react-native-image-slider/