Skip to content

Commit a0823f3

Browse files
ShivrajShivraj
Shivraj
authored and
Shivraj
committed
deckSwiper onswiping fixed
1 parent 122505e commit a0823f3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Components/Widgets/DeckSwiper.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default class CardSwiper extends NativeBaseComponent {
6767

6868

6969
swipeRight() {
70-
this.props.onSwiping('right');
70+
if(this.props.onSwiping)
71+
this.props.onSwiping('right');
7172
setTimeout( () => {
7273
Animated.timing(
7374
this.state.fadeAnim,
@@ -86,7 +87,8 @@ export default class CardSwiper extends NativeBaseComponent {
8687
}
8788

8889
swipeLeft() {
89-
this.props.onSwiping('left');
90+
if(this.props.onSwiping)
91+
this.props.onSwiping('left');
9092
setTimeout( () => {
9193
Animated.timing(
9294
this.state.fadeAnim,
@@ -119,10 +121,12 @@ export default class CardSwiper extends NativeBaseComponent {
119121

120122
onPanResponderMove: (e, gestureState) => {
121123
if (gestureState.dx > 20){
122-
this.props.onSwiping('right',gestureState.dx);
124+
if(this.props.onSwiping)
125+
this.props.onSwiping('right',gestureState.dx);
123126
}
124127
else if (gestureState.dx < -20){
125-
this.props.onSwiping('left',gestureState.dx);
128+
if(this.props.onSwiping)
129+
this.props.onSwiping('left',gestureState.dx);
126130
}
127131
let val = Math.abs((gestureState.dx*.0013));
128132
let opa = Math.abs((gestureState.dx*.0022));
@@ -143,7 +147,8 @@ export default class CardSwiper extends NativeBaseComponent {
143147
},
144148

145149
onPanResponderRelease: (e, {vx, vy}) => {
146-
this.props.onSwiping(null);
150+
if(this.props.onSwiping)
151+
this.props.onSwiping(null);
147152
var velocity;
148153

149154
if (vx >= 0) {
@@ -184,7 +189,8 @@ export default class CardSwiper extends NativeBaseComponent {
184189
card1Top: !this.state.card1Top,
185190
card2Top: !this.state.card2Top
186191
});
187-
this.props.onSwiping(null);
192+
if(this.props.onSwiping)
193+
this.props.onSwiping(null);
188194

189195
}
190196

0 commit comments

Comments
 (0)