New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-deck-swiper

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-deck-swiper

Awesome tinder like card swiper for react-native. Highly Customizable!

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.1K
increased by9.98%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-deck-swiper

contributions welcome Standard - JavaScript Style Guide npm version

Installation

npm install react-native-deck-swiper --save

Preview

App preview

Props

Card props

Propstypedescriptionrequired or default
cardsarrayarray of data for the cards to be renderedrequired
renderCardfuncfunction to render the card based on the datarequired
onSwipedAllfuncfunction to be called when all cards have been swiped() => {}
onSwipedfuncfunction to be called when a card is swiped. it receives the swiped card index(cardIndex) => {}
onSwipedLeftfuncfunction to be called when a card is swiped left. it receives the swiped card index(cardIndex) => {}
onSwipedRightfuncfunction to be called when a card is swiped right. it receives the swiped card index(cardIndex) => {}
onSwipedTopfuncfunction to be called when a card is swiped top. it receives the swiped card index(cardIndex) => {}
onSwipedBottomfuncfunction to be called when a card is swiped bottom. it receives the swiped card index(cardIndex) => {}
cardIndexnumbercardIndex to start with0
infiniteboolkeep swiping indefinitelyfalse

Swipe animation props

Propstypedescriptionrequired or default
verticalThresholdnumbervertical swipe thresholdheight / 5
horizontalThresholdnumberhorizontal swipe thresholdwidth / 4
swipeAnimationDurationnumberduration of the swipe animation350

Zoom animation props

Propstypedescriptionrequired or default
secondCardZoomnumbersecond card zoom0.97
zoomAnimationDurationnumberduration of the zoom animation100
zoomFrictionnumberzoom spring animation friction7

Rotation animation props

Propstypedescriptionrequired or default
inputRotationRangearrayx values range for the rotation output[-width / 2, 0, width / 2]
outputRotationRangearrayrotation values for the x values in inputRotationRange["-10deg", "0deg", "10deg"]

Opacity animation props

Propstypedescriptionrequired or default
animateOpacityboolanimate opacityfalse
inputOpacityRangeXarraypan x opacity input range[-width / 2, -width / 3, 0, width / 3, width / 2]
outputOpacityRangeXarrayopacity values for the values in inputOpacityRange[0.8, 1, 1, 1, 0.8]
inputOpacityRangeYarraypan y opacity input range[-height / 2, -height / 3, 0, height / 3, height / 2]
outputOpacityRangeYarrayopacity values for the values in inputOpacityRange[0.8, 1, 1, 1, 0.8]

Swipe back animation props

Propstypedescriptionrequired or default
previousCardInitialPositionXnumberinitial x position of the swipe back card0
previousCardInitialPositionYnumberinitial y position of the swipe back card-height
swipeBackAnimationDurationnumberswipe back animation duration600
swipeBackFrictionnumberswipe back spring animation friction11

Style props

Propstypedescriptionrequired or default
backgroundColornumberbackground color for the view containing the cards'#4FD0E9'
marginTopnumbermarginTop for the swiper container0
marginBottomnumbermarginBottom for the swiper container0
cardVerticalMarginnumbercard vertical margin60
cardHorizontalMarginnumbercard horizontal margin20

Methods

To trigger imperative animations, you can use a reference to the Swiper component.

Propsargumentsdescription
swipeBackcallback(previousCardIndex)swipe to the previous card
jumpToCardIndexcardIndexset the current card index

Usage example

Example usage with a pressable button contained in the component.

render () {
    <View style={styles.container}>
        <Swiper
            cards={['DO', 'MORE', 'OF', 'WHAT', 'MAKES', 'YOU', 'HAPPY']}
            renderCard={(card) => {
                return (
                    <View style={styles.card}>
                        <Text style={styles.text}>{card}</Text>
                    </View>
                )
            }}
            onSwiped={(cardIndex) => {console.log(cardIndex)}}
            onSwipedAll={() => {console.log('onSwipedAll')}}
            cardIndex={0}
            backgroundColor={'#4FD0E9'}>
            <Button 
                onPress={() => {console.log('oulala')}} 
                title="Press me">
                You can press me
            </Button>
        </Swiper>
    </View>
}

Demo inside the Exemples Folder

Stylesheet example


const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#F5FCFF'
  },
  card: {
    flex: 1,
    borderRadius: 4,
    borderWidth: 2,
    borderColor: '#E8E8E8',
    justifyContent: 'center',
    backgroundColor: 'white',
  },
  text: {
    textAlign: 'center',
    fontSize: 50,
    backgroundColor: 'transparent'
  }
})

Todo(contributions are welcome)

Underlaying card offset to achieve a stack effect

Keywords

FAQs

Package last updated on 24 Apr 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc