react-native-swipable-cards
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "react-native-swipable-cards", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Swipable cards with different behaviors", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -15,6 +15,2 @@ import React, { Component } from 'react' | ||
const warn = (...args) => { | ||
//console.warn(...args) | ||
} | ||
class SwipableCards extends Component { | ||
@@ -32,2 +28,6 @@ constructor(props) { | ||
log = (...args) => { | ||
this.props.logger(...args) | ||
} | ||
_goToNextCard() { | ||
@@ -74,4 +74,8 @@ let newIdx = this.state.currentCardIdx + 1 | ||
this._panResponder = PanResponder.create({ | ||
onMoveShouldSetPanResponder: (evt, gestureState) => { | ||
return Math.abs(gestureState.dx) > 5 | ||
onResponderTerminationRequest: () => false, | ||
onShouldBlockNativeResponder: () => true, | ||
onMoveShouldSetPanResponder: (evt, { dx }) => Math.abs(dx) > 5, | ||
onPanResponderTerminate: () => { | ||
this._backToDeck() | ||
}, | ||
@@ -107,8 +111,5 @@ | ||
duration: 200, | ||
}).start(this._resetState.bind(this)) | ||
}).start(this._resetState) | ||
} else { | ||
Animated.spring(this.state.pan, { | ||
toValue: {x: 0, y: 0}, | ||
friction: 4, | ||
}).start() | ||
this._backToDeck() | ||
} | ||
@@ -119,3 +120,10 @@ } | ||
_resetState() { | ||
_backToDeck = () => { | ||
Animated.spring(this.state.pan, { | ||
toValue: {x: 0, y: 0}, | ||
friction: 4, | ||
}).start() | ||
} | ||
_resetState = () => { | ||
this.state.pan.setValue({x: 0, y: 0}) | ||
@@ -146,4 +154,2 @@ this.state.enter.setValue(0) | ||
warn('RENDER card') | ||
return ( | ||
@@ -161,3 +167,2 @@ <Animated.View | ||
renderStackCard(card, style) { | ||
warn('RENDER STACK card') | ||
return ( | ||
@@ -195,4 +200,2 @@ <Animated.View | ||
warn(`style for ${i}`, { offsetX, offsetY, lastOffsetX, lastOffsetY }) | ||
return this.renderStackCard(card, style) | ||
@@ -203,3 +206,2 @@ }) | ||
render() { | ||
warn('RENDER TOTAL!!!') | ||
let { pan } = this.state | ||
@@ -227,4 +229,4 @@ | ||
<Animated.View style={[this.props.nopeStyle, animatedNopeStyles]}> | ||
{this.props.noView | ||
? this.props.noView | ||
{this.props.nopeView | ||
? this.props.nopeView | ||
: <Text style={this.props.nopeTextStyle}>{this.props.nopeText}</Text> | ||
@@ -318,3 +320,6 @@ } | ||
renderCard: React.PropTypes.func, | ||
renderYup: React.PropTypes.func, | ||
renderNope: React.PropTypes.func, | ||
renderNoMoreCards: React.PropTypes.func, | ||
logger: React.PropTypes.func, | ||
} | ||
@@ -342,4 +347,5 @@ | ||
onCardRemoved: () => null, | ||
logger: () => null, | ||
} | ||
export default SwipableCards |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13569
291