Coder Social home page Coder Social logo

easyui / react-native-ezswiper Goto Github PK

View Code? Open in Web Editor NEW
133.0 10.0 51.0 8.05 MB

swiper component for react-native

License: MIT License

JavaScript 100.00%
react-native react swiper android ios react-native-ezswiper javascript card pageview react-native-ezswiper-js

react-native-ezswiper's Introduction

react-native-ezswiper

中文文档

NPM version release GitHub license

source is simple, easy to use card swiper for React Native on iOS&android.

Installation

$ npm install react-native-ezswiper --save

Preview

showios showandroid

Usage

import library:

import EZSwiper from 'react-native-ezswiper';

simple swiper

<EZSwiper style={{width: width,height: 150,backgroundColor: 'white'}}
          dataSource={['0', '1' ,'2','3']}
          width={ width }
          height={150 }
          renderRow={this.renderRow}
          onPress={this.onPressRow}                      
          />

card swiper

<EZSwiper style={{width: width,height: 150,backgroundColor: 'white'}}
           dataSource={images}
           width={ width }
           height={150 }
           renderRow={this.renderImageRow}
           onPress={this.onPressRow} 
           ratio={0.867}                    
                    />

advanced

<EZSwiper style={{width: width,height: 150,backgroundColor: 'white'}}
                    dataSource={['0', '1' ,'2','3']}
                    width={ width }
                    height={150 }
                    renderRow={this.renderRow}
                    onPress={this.onPressRow} 
                    index={2}                
                    cardParams={{cardSide:width*0.867, cardSmallSide:150*0.867,cardSpace:width*(1-0.867)/2*0.2}}  
                    />

vertical swiper

<EZSwiper style={{width: width,height: 200,backgroundColor: 'white'}}
          dataSource={['0', '1' ,'2','3']}
          width={ width }
          height={200 }
          renderRow={this.renderRow}
          onPress={this.onPressRow} 
          ratio={0.867} 
          horizontal={false}  
                    />

API

Props

key type default description
width PropTypes.number.isRequired swiper width
height PropTypes.number.isRequired swiper height
index PropTypes.number 0 initial index
offset PropTypes.number 0 initial left and right or up and down offsets
horizontal PropTypes.bool true swiper derection is horizontal
loop PropTypes.bool true swiper is loop
autoplayTimeout PropTypes.number 5 auto play mode (in second)
autoplayDirection PropTypes.bool true cycle direction control
ratio PropTypes.number 1 scaling ratio
cardParams PropTypes.object {} swiper card advanced object
renderRow PropTypes.func.isRequired render card view
onPress PropTypes.func card is clicked action
onWillChange PropTypes.func next card will show
onDidChange PropTypes.func next card showed

cardParams is object:{cardSide,cardSmallSide,cardSpace}

cardParams

Function

function description
scrollTo(index, animated = true) scroll to position

License

MIT License. © Zhu Yangjun 2017

react-native-ezswiper's People

Contributors

easyui avatar zhazhengrefn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-ezswiper's Issues

真机卡顿

滑动的时候,真机卡顿,我打了断点,滑动的时候做了过多的计算,十张左右卡片,滑动一次,计算了大概超过300次

renderRow中返回组件,但是iOS和android真机上都显示不出来,通过iOS图层看到是有存在组件的

`<EZSwiper
style={{
width: screenW,
height: scaleHeight(150),
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center'
}}
dataSource={this.state.banaListData}
width={screenW}
height={scaleHeight(150)}
renderRow={this.renderBananaRowView}
ratio={0.875}
/>
renderBananaRowView(item) {

    return (
        <View
            key={item}
            style={{
                width: (screenW) * 0.875,
                height: scaleHeight(150),
                backgroundColor: 'blue',
                borderRadius: 10,
                justifyContent: 'center',
                alignItems: 'center'
            }}
        >
            <Image
                // source={{ uri: item.pic }}
                source={require('../../Resource/defaultIcon/small_default_image.png')}
                style={{
                    width: (screenW) * 0.875,
                    height: scaleHeight(150),
                    borderRadius: 10,
                    backgroundColor: '#f4f4f4',
                }}
            />
        </View>
    );
}`

点击事件不触发

<EZSwiper style={{height: scaleSize(85), width: screenSize.width}} dataSource={['0', '1', '2']} loop={false} width={screenSize.width} height={scaleSize(85)} renderRow={this.renderRow} onPress={v => { console.log(v); }} index={1} ratio={0.8} />
最左边显示的组件点击不会触发点击事件

重新渲染会出现问题

重新渲染后会报错。
排查后发现是代码中 componentWillReceiveProps函数
把nextProps错误的写成了this.nextProps

android上开发过程中

android上开发过程中,ezswiper在滑动到断点(['0', '1' ,'2','3'],在0和3的切换时)的时候会闪一下,请问还有其他人遇到的吗?这问题解决了没?

onDidChange获取到的index有问题

onDidChange获取到的index有问题,从后往前返回时,获取不到正确的index(当滚动到第一个时获取到的index依然是1)

Props feature request

Instead of dataSource prop can you please create a prop that just takes the dataSource length.I thought of working around by making changes in the EZSwiper.js component in the react-native-ezswiper node modules package but i couldn't understand the workaround so i just left. 😛

android 开发过程有问题

card swiper 在android上开发过程中,swiper在滑动到断点(['0', '1' ,'2','3'],在0和3的切换时)的时候会闪一下
还有就是android开发环境中到了最后一个元素后不能自动轮播, 就停止在哪里
untitled

滑动速度

你好,可以添加一个垂直或者水平滑动速度的属性吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.