1.1.1 • Published 4 years ago

react-native-hooks-swiper v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Tips: This component has been moved to the new new npm & github repository named "react-native-swiper-hooks".

you can still use this component, but I will updata it only on the new repository


npm.io npm.io npm.io npm.io npm.io

npm.io npm.io npm.io npm.io npm.io

Hello, folks!

🦄 This is a wonderful animated carsouel hooks component for React-Native

✨ 为React Native开发的轮播展示动画组件

👨🏻‍💻 Powered by Voyz Shen

🏫 Shanghai Jiao Tong University, Ctrip

react-native-hooks-swiper

Catalog


Demo

autoplay ↓

autoplay

non-autoplay ↓

no_autoplay.gif

non-loop ↓

non-loop.gif


How to use

  • install
npm i react-native-hooks-swiper --save
  • import
import Swiper from 'react-native-hooks-swiper'
  • Demo
...
const _renderList = ()=>{
	 let listData = [
      {
        title:'1',
        bgColor:'#f00'
      },
      {
        title:'2',
        bgColor:'#0f0'
      },
      {
        title:'3',
        bgColor:'#00f'
      },
    ]
    return (
      listData.map((item,idx)=>{
        return (
          <View style={{width:WIDTH,height:300,backgroundColor:item.bgColor,justifyContent: 'center',alignItems: 'center'}} key={idx}>
              <Text>{item.title}</Text>
          </View>
        )
      })
    )
}

...

<Swiper height={300}
        autoplay={true}
        loop={true}
        showPagination={true}
        bounces={false}>
  {_renderList()}
</Swiper>

...

Properties

pagination-shower.jpg

- Basic -

PropDefaultOptionsTypeDescription
widthwidth of screen/NumberWidth of the Swiper container
容器宽度
heightheight of screen/NumberHeight of the Swiper container
容器高度
boxBackgroundColor//ColorBackground color of the Swiper container
容器背景颜色
initIndex0/NumberIndex of the init child
初始页
direction'row''row' / 'column'StringDirection of the scrolling
滚动方向
minOffset10/NumberThreshold of scroll distance for page turning
翻页的滚动阈值
autoplaytruetrue / falseBooleanEnable autoplay
是否自动播放
looptruetrue / falseBooleanEnable loop mode
是否循环滚动
autoplayGapTime3/Numbersecond between autoplay transitions
自动播放时间间隔
autoplayDirectiontruetrue / falseBooleanEnable forward direction when autoplay
是否正向自动播放
scrollEnabledtruetrue / falseBooleanEnable hand-rolling
是否可以手动滚动
animatedtruetrue / falseBooleanEnable smooth scrolling animation
是否开启滚动动画
bouncestruetrue / falseBooleanEnable pull flexibly when you scroll to the head and tail
到达首尾时是否可以弹性拉动一截

- Pagination -

PropDefaultOptionsTypeDescription
showPaginationtruetrue / falseBooleanEnable pagination shower
是否显示页码器
paginationDirection'bottom''bottom' / 'top' / 'left' / 'right'StringPosition of the pagination
页码器位置
paginationOffset5/NumberDistance between pagination shower and side
页码器距边距离
paginationUnselectedSize6/NumberSize of the point (non-current)
提示点大小(非当前页)
paginationSelectedSize10/NumberSize of the point (current)
提示点大小(当前页)
paginationUnselectedColor'#FFFFFF'/ColorColor of the point (non-current)
提示点颜色(非当前页)
paginationSelectedSize'#000000'/ColorColor of the point (current)
提示点颜色(当前页)

Functions

- callback -

FuncParamsTypeDescription
onPaginationChangeindexNumberRetrun the index of current page when it changes
页码改变时返回当前页码索引
onScrollBeginDragnativeEventObjectCallback on scroll begin drag
开始拖动时的回调函数
onScrollEndDragnativeEventObjectCallback on scroll end drag
结束拖动时的回调函数
1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago