Skip to content

Feat/improve pan #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/components/panningViews/panDismissibleView.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PanDismissibleView extends PureComponent {
const {directions} = this.props;
if (this.swipe.x || this.swipe.y) {
const {isRight, isDown} = this.getDismissAnimationDirection();
this.animateDismiss(isRight, isDown);
this._animateDismiss(isRight, isDown);
} else {
const endValue = {x: Math.round(this.left), y: Math.round(this.top)};
if (
Expand All @@ -154,7 +154,7 @@ class PanDismissibleView extends PureComponent {
(directions.includes(PanningProvider.Directions.DOWN) && endValue.y >= this.thresholdY)
) {
const {isRight, isDown} = this.getDismissAnimationDirection();
this.animateDismiss(isRight, isDown);
this._animateDismiss(isRight, isDown);
} else {
this.animateToInitialPosition();
}
Expand Down Expand Up @@ -226,7 +226,23 @@ class PanDismissibleView extends PureComponent {
return {isRight, isDown};
};

animateDismiss = (isRight, isDown) => {
// Send undefined to not animate in the horizontal\vertical direction
// isRight === true --> animate to the right
// isRight === false --> animate to the left
// isDown === true --> animate to the bottom
// isDown === false --> animate to the top
animateDismiss = () => {
const {directions = []} = this.props;
const hasUp = directions.includes(PanningProvider.Directions.UP);
const hasRight = directions.includes(PanningProvider.Directions.RIGHT);
const hasLeft = directions.includes(PanningProvider.Directions.LEFT);
const hasDown = !hasUp && !hasLeft && !hasRight; // default
const verticalDismiss = hasDown ? true : hasUp ? false : undefined;
const horizontalDismiss = hasRight ? true : hasLeft ? false : undefined;
this._animateDismiss(horizontalDismiss, verticalDismiss);
};

_animateDismiss = (isRight, isDown) => {
const {animTranslateX, animTranslateY} = this.state;
const {duration} = this.props.animationOptions;
const animations = [];
Expand Down