You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-native-cards-swipe

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-cards-swipe

Powerful RN Card Swiper

1.2.1
latest
Source
npmnpm
Version published
Weekly downloads
115
Maintainers
1
Weekly downloads
 
Created
Source

react-native-cards-swipe

Powerful React Native Card Stack Swiper

contributions welcome npm version npm downloads

Preview

App preview

Installation

  • Install the react-native-cards-swipe package.
npm install react-native-cards-swipe

Usage

import React from 'react';
import { Image, StyleSheet, View } from 'react-native';

import CardsSwipe from 'react-native-cards-swipe';

const cardsData = [
  { src: require('./assets/images/1.jpg') },
  { src: require('./assets/images/2.jpg') },
  { src: require('./assets/images/3.jpg') },
  { src: require('./assets/images/4.jpg') },
];

export default function App() {
  return (
    <View style={styles.container}>
      <CardsSwipe
        cards={cardsData}
        cardContainerStyle={styles.cardContainer}
        renderCard={(card) => (
          <View style={styles.card}>
            <Image
              style={styles.cardImg}
              source={card.src}
            />
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  cardContainer: {
    width: '92%',
    height: '70%',
  },
  card: {
    width: '100%',
    height: '100%',
    shadowColor: '#000000',
    shadowOffset: {
      width: 0,
      height: 8,
    },
    shadowOpacity: 0.07,
    shadowRadius: 3.3,
  },
  cardImg: {
    width: '100%',
    height: '100%',
    borderRadius: 13,
  },
});

CardsSwipe props

Propstypedescriptionrequireddefault
cardsarraydata for the cardsyes
renderCardfuncrenders the card with the current datayes
initialIndexnumberinitial card index0
containerStyleobjectcontainer style{}
cardContainerStyleobjectcardContainerStyle style{}
lowerCardZoomnumberlower card zoom0.95
animDurationnumbercard animation duration150
horizontalThresholdnumberhorizontal swipe thresholdwidth * 0.65
rotationAnglenumberrotation angle (deg) for the card10
loopboolkeep swiping indefinitelytrue
renderNoMoreCardfuncrenders what is shown after swiped last card() => null
renderYepfuncrenders Yep label() => null
renderNopefuncrenders Nope label() => null
onSwipeStartfuncfunction to be called when a card swipe starts() => {}
onSwipeChangeDirectionfuncfunction to be called when a card is active and changes its direction (left, right).() => {}
onSwipeEndfuncfunction to be called when a card swipe ends (card is released)() => {}
onSwipedfuncfunction to be called when a card is swiped. it receives the swiped card index() => {}
onSwipedLeftfuncfunction to be called when a card is swiped left. it receives the swiped card index() => {}
onSwipedRightfuncfunction to be called when a card is swiped right. it receives the swiped card index() => {}
onNoMoreCardsfuncfunction to be called when all elements in array are finished() => {}

CardsSwipe actions

Propstype
swipeLeftfunc
swipeRightfunc
  <CardsSwipe ref={swiper => { this.swiper = swiper }} />

  <TouchableOpacity onPress={ () => { this.swiper.swipeLeft() }}>
    <Text>Left</Text>
  </TouchableOpacity>

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Keywords

react-native

FAQs

Package last updated on 12 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts