Skip to content

Commit

Permalink
Merge branch 'feature/use-native-driver' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Micasso authored and Micasso committed Sep 15, 2020
2 parents e88b194 + af0b279 commit c59fa8c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions SwipeCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class SwipeCards extends Component {

onPanResponderMove: Animated.event([
null, { dx: this.state.pan.x, dy: this.props.dragY ? this.state.pan.y : 0 },
]),
], { useNativeDriver: false }),

onPanResponderRelease: (e, {vx, vy, dx, dy}) => {
this.props.onDragRelease()
Expand Down Expand Up @@ -235,7 +235,8 @@ export default class SwipeCards extends Component {
} else {
this.cardAnimation = Animated.decay(this.state.pan, {
velocity: { x: velocity, y: vy },
deceleration: 0.98
deceleration: 0.98,
useNativeDriver: true,
});
this.cardAnimation.start(status => {
if (status.finished) this._advanceState();
Expand All @@ -256,39 +257,39 @@ export default class SwipeCards extends Component {
_forceLeftSwipe() {
this.cardAnimation = Animated.timing(this.state.pan, {
toValue: { x: -500, y: 0 },
}).start(status => {
useNativeDriver: true,
}).start((status) => {
if (status.finished) this._advanceState();
else this._resetState();

this.cardAnimation = null;
}
);
});
this.props.cardRemoved(currentIndex[this.guid]);
}

_forceUpSwipe() {
this.cardAnimation = Animated.timing(this.state.pan, {
toValue: { x: 0, y: 500 },
}).start(status => {
useNativeDriver: true,
}).start((status) => {
if (status.finished) this._advanceState();
else this._resetState();

this.cardAnimation = null;
}
);
});
this.props.cardRemoved(currentIndex[this.guid]);
}

_forceRightSwipe() {
this.cardAnimation = Animated.timing(this.state.pan, {
toValue: { x: 500, y: 0 },
}).start(status => {
useNativeDriver: true,
}).start((status) => {
if (status.finished) this._advanceState();
else this._resetState();

this.cardAnimation = null;
}
);
});
this.props.cardRemoved(currentIndex[this.guid]);
}

Expand Down Expand Up @@ -328,10 +329,11 @@ export default class SwipeCards extends Component {
}

_animateEntrance() {
Animated.spring(
this.state.enter,
{ toValue: 1, friction: 8 }
).start();
Animated.spring(this.state.enter, {
toValue: 1,
friction: 8,
useNativeDriver: true,
}).start();
}

componentWillReceiveProps(nextProps) {
Expand All @@ -353,7 +355,8 @@ export default class SwipeCards extends Component {
_resetPan() {
Animated.spring(this.state.pan, {
toValue: { x: 0, y: 0 },
friction: 4
friction: 4,
useNativeDriver: true,
}).start();
}

Expand Down

0 comments on commit c59fa8c

Please sign in to comment.