react-native-cards-slider

a simple react native component like airbnb's cards slider.

  • 所有者: LIU9293/react-native-cards-slider
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

A simple cards slider like airbnb has

preview.gif

Autoplay (new)

<CardSilder autoplay interval={4000}>
  {YOUR_AWESOME_CHILDREN}
</CardSilder>

Usage

npm i react-native-cards-slider --save

example:

import CardSilder from 'react-native-cards-slider';

class example extends Component{
  render(){
    return(
      <CardSilder>
        <Image style={{height: 170}} source={{url : 'YOU_IMAGE_URL'}} />
        <Image style={{height: 170}} source={{url : 'YOU_IMAGE_URL'}} />
        <Image style={{height: 170}} source={{url : 'YOU_IMAGE_URL'}} />
        <Image style={{height: 170}} source={{url : 'YOU_IMAGE_URL'}} />
      </CardSilder>
    )
  }
}

complete example in preview gif:

import React, { Component } from 'react';
import { Image, AppRegistry, Text, View } from 'react-native';
import CardSilder from 'react-native-cards-slider';

class App extends Component{
  render(){
    return(
      <View>
        <Text style={{fontSize: 30, color: '#000', marginTop:50, marginLeft:20, fontWeight:'bold'}}>
          Images
        </Text>
        <CardSilder style={{marginTop: 30}}>
          <Image style={{height: 170}} source={{url : 'YOUR_IMAGE'}} />
          <Image style={{height: 170}} source={{url : 'YOUR_IMAGE'}} />
          <Image style={{height: 170}} source={{url : 'YOUR_IMAGE'}} />
          <Image style={{height: 170}} source={{url : 'YOUR_IMAGE'}} />
        </CardSilder>
        <Text style={{fontSize: 30, color: '#000', marginTop:40, marginLeft:20, fontWeight:'bold'}}>
          Block with Text
        </Text>
        <CardSilder style={{marginTop: 30}}>
          <View style={{height: 170, justifyContent:'center', alignItems:'center', backgroundColor: 'skyblue'}}>
            <Text style={{color: 'white', fontSize: 24, fontWeight: 'bold'}}>
              悉尼
            </Text>
          </View>
          <View style={{height: 170, justifyContent:'center', alignItems:'center', backgroundColor: 'lightsalmon'}}>
            <Text style={{color: 'white', fontSize: 24, fontWeight: 'bold'}}>
              纽约
            </Text>
          </View>
          <View style={{height: 170, justifyContent:'center', alignItems:'center', backgroundColor: 'teal'}}>
            <Text style={{color: 'white', fontSize: 24, fontWeight: 'bold'}}>
              东京
            </Text>
          </View>
          <View style={{height: 170, justifyContent:'center', alignItems:'center', backgroundColor: 'lightpink'}}>
            <Text style={{color: 'white', fontSize: 24, fontWeight: 'bold'}}>
              上海
            </Text>
          </View>
        </CardSilder>
      </View>
    )
  }
}

AppRegistry.registerComponent('YOUR_APP_NAME', () => App);

CardSilder itself will set it's width to the device width.

So make sure you have enough space for it, and DO set a height for the children components.

Pull request welcome.

主要指標

概覽
名稱與所有者LIU9293/react-native-cards-slider
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證
所有者活动
創建於2016-09-23 15:16:06
推送於2020-06-03 16:10:29
最后一次提交2016-10-07 00:24:04
發布數0
用户参与
星數49
關注者數0
派生數8
提交數6
已啟用問題?
問題數5
打開的問題數3
拉請求數0
打開的拉請求數1
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?