diff --git a/CardStack.js b/CardStack.js
index b83f65c..48e2458 100644
--- a/CardStack.js
+++ b/CardStack.js
@@ -92,6 +92,7 @@ class CardStack extends Component {
this._nextCard('right', swipeDirection, gestureState.dy, this.props.duration);
}
else {
+ this.props.onSwipeCancel()
this._resetCard();
}
} else if (((Math.abs(gestureState.dy) > verticalThreshold) ||
@@ -108,10 +109,12 @@ class CardStack extends Component {
this._nextCard('bottom', gestureState.dx, swipeDirection, this.props.duration);
}
else {
+ this.props.onSwipeCancel()
this._resetCard();
}
}
else {
+ this.props.onSwipeCancel()
this._resetCard();
}
},
@@ -142,7 +145,7 @@ class CardStack extends Component {
}
_getIndex(index, cards){
- return this.props.loop ?
+ return this.props.loop ?
this.mod(index, cards):
index;
}
@@ -475,6 +478,7 @@ CardStack.propTypes = {
renderNoMoreCards: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
onSwipeStart: PropTypes.func,
onSwipeEnd: PropTypes.func,
+ onSwipeCancel: PropTypes.func,
onSwiped: PropTypes.func,
onSwipedLeft: PropTypes.func,
onSwipedRight: PropTypes.func,
@@ -507,6 +511,7 @@ CardStack.defaultProps = {
renderNoMoreCards: () => { return (No More Cards) },
onSwipeStart: () => null,
onSwipeEnd: () => null,
+ onSwipeCancel: () => null,
onSwiped: () => { },
onSwipedLeft: () => { },
onSwipedRight: () => { },
diff --git a/index.d.ts b/index.d.ts
index 112c474..6556b87 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -16,7 +16,8 @@ export interface CardStackProps {
horizontalThreshold?: number;
outputRotationRange?: [string, string, string]
onSwipeStart?: (index: number) => void;
- onSwipeEnd?: (index: number) => void;
+ onSwipeEnd?: (index: number) => void;
+ onSwipeCancel?: () => void;
onSwiped?: (index: number) => void;
onSwipedLeft?: (index: number) => void;
onSwipedRight?: (index: number) => void;
@@ -48,4 +49,4 @@ export interface CardProps {
export class Card extends React.Component {
constructor(props: CardProps);
-}
\ No newline at end of file
+}