Gathering detailed insights and metrics for react-native-deck-swiper
Gathering detailed insights and metrics for react-native-deck-swiper
Gathering detailed insights and metrics for react-native-deck-swiper
Gathering detailed insights and metrics for react-native-deck-swiper
react-native-snap-carousel
Swiper/carousel component for React Native with previews, multiple layouts, parallax images, performant handling of huge numbers of items, and RTL support. Compatible with Android & iOS.
@perroudsky/react-native-deck-swiper
Awesome tinder like card swiper for react-native. Highly Customizable!
@coorpacademy/react-native-deck-swiper
Awesome tinder like card swiper for react-native. Highly Customizable!
@agungkes/react-native-deck-swiper
Awesome tinder like card swiper for react-native. Highly Customizable!
npm install react-native-deck-swiper
Typescript
Module System
Node Version
NPM Version
54.8
Supply Chain
56
Quality
67.8
Maintenance
50
Vulnerability
93.4
License
JavaScript (83.18%)
Objective-C (9.83%)
Starlark (3.85%)
Java (3.13%)
Total Downloads
920,301
Last Day
948
Last Week
5,415
Last Month
24,623
Last Year
248,567
146 Stars
362 Commits
84 Forks
4 Watching
6 Branches
1 Contributors
Latest Version
2.0.17
Package Id
react-native-deck-swiper@2.0.17
Unpacked Size
2.21 MB
Size
1.72 MB
File Count
14
NPM Version
7.21.1
Node Version
18.16.1
Publised On
26 Feb 2024
Cumulative downloads
Total Downloads
Last day
-19.5%
948
Compared to previous day
Last week
-23.9%
5,415
Compared to previous week
Last month
16.6%
24,623
Compared to previous month
Last year
18.8%
248,567
Compared to previous year
1
2
18
yarn add react-native-deck-swiper
OR
npm install react-native-deck-swiper --save
Version 2.0.0-beta is technically version 1.7.2 of the package. However, npm recommended that due to the change in ownership the version be bumped.
react-native-deck-swiper | react-native | description |
---|---|---|
<= 2.0.3-beta | <= 0.56.x | should install react-native-view-overflow and set useViewOverflow true |
>= 2.0.4 | => 0.57.x | no longer requires react-native-view-overflow; useViewOverflow removed |
Before submitting a new issue please check if it hasn't already been reported yet. With respect to bugfixes and further developments, please check the To Do board.
Props | type | description | required | default |
---|---|---|---|---|
cards | array | array of data for the cards to be rendered | required | |
renderCard | func(cardData, cardIndex) | function to render the card based on the data | required | |
keyExtractor | func(cardData) | function to get the card's react key | null | |
cardIndex | number | cardIndex to start with | 0 | |
infinite | bool | keep swiping indefinitely | false | |
horizontalSwipe | bool | enable/disable horizontal swiping | true | |
verticalSwipe | bool | enable/disable vertical swiping | true | |
showSecondCard | bool | enable/disable second card while swiping | true | |
stackSize | number | number of underlaying cards to show (showSecondCard must be enabled) | 1 |
Props | type | description | default |
---|---|---|---|
onSwipedAll | func | function to be called when all cards have been swiped | |
onSwiped | func | function to be called when a card is swiped. it receives the swiped card index | |
onSwipedAborted | func | function to be called when a card is released before reaching the threshold | |
onSwipedLeft | func | function to be called when a card is swiped left. it receives the swiped card index | |
onSwipedRight | func | function to be called when a card is swiped right. it receives the swiped card index | |
onSwipedTop | func | function to be called when a card is swiped top. it receives the swiped card index | |
onSwipedBottom | func | function to be called when a card is swiped bottom. it receives the swiped card index | |
onSwiping | func | function to be called when a card is being moved. it receives X and Y positions | |
dragStart | func | function to be called when drag start | |
dragEnd | func | function to be called when drag end | |
onTapCard | func | function to be called when tapping a card. it receives the tapped card index | |
onTapCardDeadZone | number | maximum amount of movement before a tap is no longer recognized as a tap | 5 |
Props | type | description | default |
---|---|---|---|
verticalThreshold | number | vertical swipe threshold | height / 5 |
horizontalThreshold | number | horizontal swipe threshold | width / 4 |
swipeAnimationDuration | number | duration of the swipe animation | 350 |
disableBottomSwipe | bool | disable bottom swipe | false |
disableLeftSwipe | bool | disable left swipe | false |
disableRightSwipe | bool | disable right swipe | false |
disableTopSwipe | bool | disable top swipe | false |
Props | type | description | default |
---|---|---|---|
stackSeparation | number | vertical separation between underlaying cards | 10 |
stackScale | number | percentage to reduce the size of each underlaying card | 3 |
stackAnimationFriction | number | spring animation friction (bounciness) | 7 |
stackAnimationTension | number | spring animation tension (speed) | 40 |
Props | type | description | default |
---|---|---|---|
inputRotationRange | array | x values range for the rotation output | [-width / 2, 0, width / 2] |
outputRotationRange | array | rotation values for the x values in inputRotationRange | ["-10deg", "0deg", "10deg"] |
Props | type | description | default |
---|---|---|---|
animateCardOpacity | bool | animate card opacity | false |
inputCardOpacityRangeX | array | pan x card opacity input range | [-width / 2, -width / 3, 0, width / 3, width / 2] |
outputCardOpacityRangeX | array | opacity values for the values in inputCardOpacityRangeX | [0.8, 1, 1, 1, 0.8] |
inputCardOpacityRangeY | array | pan y card opacity input range | [-height / 2, -height / 3, 0, height / 3, height / 2] |
outputCardOpacityRangeY | array | opacity values for the values in inputCardOpacityRangeY | [0.8, 1, 1, 1, 0.8] |
animateOverlayLabelsOpacity | bool | animate card overlay labels opacity | false |
inputOverlayLabelsOpacityRangeX | array | pan x overlay labels opacity input range | [-width / 3, -width / 4, 0, width / 4, width / 3] |
outputOverlayLabelsOpacityRangeX | array | opacity values for the values in inputOverlayLabelsOpacityRangeX | [1, 0, 0, 0, 1] |
inputOverlayLabelsOpacityRangeY | array | pan x overlay labels opacity input range | [-height / 4, -height / 5, 0, height / 5, height / 4] |
outputOverlayLabelsOpacityRangeY | array | opacity values for the values in inputOverlayLabelsOpacityRangeY | [1, 0, 0, 0, 1] |
overlayOpacityVerticalThreshold | number | vertical threshold for overlay label | height / 5 |
overlayOpacityHorizontalThreshold | number | horizontal threshold for overlay label | width / 4 |
2 steps of inputOverlayLabelsOpacityRangeX and inputOverlayLabelsOpacityRangeY should match horizontalThreshold and verticalThreshold, respectively.
Props | type | description | default |
---|---|---|---|
overlayLabels | object | swipe labels title and style | null, see below for format |
overlayLabelStyle | object | swipe labels style | null, see below for format |
overlayLabelWrapperStyle | object | overlay label wrapper style | see below for default |
1{ 2 fontSize: 45, 3 fontWeight: 'bold', 4 borderRadius: 10, 5 padding: 10, 6 overflow: 'hidden' 7}
1{ 2 position: 'absolute', 3 backgroundColor: 'transparent', 4 zIndex: 2, 5 flex: 1, 6 width: '100%', 7 height: '100%' 8}
1{ 2 bottom: { 3 element: <Text>BLEAH</Text> /* Optional */ 4 title: 'BLEAH', 5 style: { 6 label: { 7 backgroundColor: 'black', 8 borderColor: 'black', 9 color: 'white', 10 borderWidth: 1 11 }, 12 wrapper: { 13 flexDirection: 'column', 14 alignItems: 'center', 15 justifyContent: 'center' 16 } 17 } 18 }, 19 left: { 20 element: <Text>NOPE</Text> /* Optional */ 21 title: 'NOPE', 22 style: { 23 label: { 24 backgroundColor: 'black', 25 borderColor: 'black', 26 color: 'white', 27 borderWidth: 1 28 }, 29 wrapper: { 30 flexDirection: 'column', 31 alignItems: 'flex-end', 32 justifyContent: 'flex-start', 33 marginTop: 30, 34 marginLeft: -30 35 } 36 } 37 }, 38 right: { 39 element: <Text>LIKE</Text> /* Optional */ 40 title: 'LIKE', 41 style: { 42 label: { 43 backgroundColor: 'black', 44 borderColor: 'black', 45 color: 'white', 46 borderWidth: 1 47 }, 48 wrapper: { 49 flexDirection: 'column', 50 alignItems: 'flex-start', 51 justifyContent: 'flex-start', 52 marginTop: 30, 53 marginLeft: 30 54 } 55 } 56 }, 57 top: { 58 element: <Text>SUPER</Text> /* Optional */ 59 title: 'SUPER LIKE', 60 style: { 61 label: { 62 backgroundColor: 'black', 63 borderColor: 'black', 64 color: 'white', 65 borderWidth: 1 66 }, 67 wrapper: { 68 flexDirection: 'column', 69 alignItems: 'center', 70 justifyContent: 'center' 71 } 72 } 73 } 74}
Make sure you set showSecondCard={false} for smoother and proper transitions while going back to previous card.
Props | type | description | default |
---|---|---|---|
goBackToPreviousCardOnSwipeLeft | bool | previous card is rendered on left swipe | false |
goBackToPreviousCardOnSwipeRight | bool | previous card is rendered on right swipe | false |
goBackToPreviousCardOnSwipeTop | bool | previous card is rendered on top swipe | false |
goBackToPreviousCardOnSwipeBottom | bool | previous card is rendered on bottom swipe | false |
Props | type | description | default |
---|---|---|---|
backgroundColor | string | background color for the view containing the cards | '#4FD0E9' |
marginTop | number | marginTop for the swiper container | 0 |
marginBottom | number | marginBottom for the swiper container | 0 |
cardVerticalMargin | number | card vertical margin | 60 |
cardHorizontalMargin | number | card horizontal margin | 20 |
childrenOnTop | bool | render children on top or not | false |
cardStyle | node | override swipable card style | {} |
containerStyle | node | overrides for the containing | {} |
pointerEvents | string | pointerEvents prop for the containing | 'auto' |
useViewOverflow | bool | use ViewOverflow instead of View for the Swiper component | true |
Name | type | description |
---|---|---|
swipeBack | callback | swipe back into deck last swiped card. stacksize should be 2 cards or more |
Props | type | description | default |
---|---|---|---|
previousCardDefaultPositionX | number | Animation start position oX when card swipes back into deck | -width |
previousCardDefaultPositionY | number | Animation start position oY when card swipes back into deck | -height |
stackAnimationFriction | number | spring animation friction (bounciness) | 7 |
stackAnimationTension | number | spring animation tension (speed) | 40 |
stackAnimationTension | number | spring animation tension (speed) | 40 |
swipeBackCard | bool | renders swipe back card, in order to animate it | false |
To trigger imperative animations, you can use a reference to the Swiper component.
Name | arguments | description |
---|---|---|
swipeLeft | mustDecrementCardIndex = false | swipe left to the next card |
swipeRight | mustDecrementCardIndex = false | swipe right to the next card |
swipeTop | mustDecrementCardIndex = false | swipe top to the next card |
swipeBottom | mustDecrementCardIndex = false | swipe bottom to the next card |
jumpToCardIndex | cardIndex | set the current card index |
1render () { 2 <View style={styles.container}> 3 <Swiper 4 cards={['DO', 'MORE', 'OF', 'WHAT', 'MAKES', 'YOU', 'HAPPY']} 5 renderCard={(card) => { 6 return ( 7 <View style={styles.card}> 8 <Text style={styles.text}>{card}</Text> 9 </View> 10 ) 11 }} 12 onSwiped={(cardIndex) => {console.log(cardIndex)}} 13 onSwipedAll={() => {console.log('onSwipedAll')}} 14 cardIndex={0} 15 backgroundColor={'#4FD0E9'} 16 stackSize= {3}> 17 <Button 18 onPress={() => {console.log('oulala')}} 19 title="Press me"> 20 You can press me 21 </Button> 22 </Swiper> 23 </View> 24}
Demo inside the Example Folder
1const styles = StyleSheet.create({ 2 container: { 3 flex: 1, 4 backgroundColor: "#F5FCFF" 5 }, 6 card: { 7 flex: 1, 8 borderRadius: 4, 9 borderWidth: 2, 10 borderColor: "#E8E8E8", 11 justifyContent: "center", 12 backgroundColor: "white" 13 }, 14 text: { 15 textAlign: "center", 16 fontSize: 50, 17 backgroundColor: "transparent" 18 } 19});
Card properties may change, including on already swiped cards, which would yield no effects to users as the cards would no longer be displayed [based on initial issue].
A possible fix for the situation is setting the cardIndex on the parent component whenever deck re-renders are needed.
const { cardIndex } = this.props;
return (<Swiper
ref={swiper => {
this.swiper = swiper;
}}
{...customSwiperProps}
cardIndex={cardIndex}
/>)
Passing along the cardIndex to the swiper will allow external changes on the property, thus triggering a re-render of the deck of cards. All onSwipe callbacks return the cardIndex that can be used to push the updated cardIndex to app state (redux or something else).
By making sure that external changes on the cardIndex match those the swiper performs (increment on swipes, decrement on swipeBack) one can ensure no re-renders occur when not needed.
If you've encountered issues while running the example app located in the example folder, try the following steps:
If you're using yarn
If you're using npm
If bundler doesn't automatically start Simply run yarn start or npm start in the Example folder.
Don't forget to bump project and example versions in package.json whenever you submit a PR.
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 15/30 approved changesets -- score normalized to 5
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
100 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More