From 78485a36ba1f1442f5039807ac274b175352b00b Mon Sep 17 00:00:00 2001 From: Fred Liu Date: Fri, 10 Jun 2016 17:26:02 -0700 Subject: [PATCH] Slower bounce Summary: Slower bounce during mount and right swipe, so it feels less jarring to users. Reviewed By: hedgerwang Differential Revision: D3420169 fbshipit-source-id: d5da87c4a64eecf478edd626c96f5541ab94b56e --- .../Experimental/SwipeableRow/SwipeableRow.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index 1f1a57244..c1cb230f5 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -52,10 +52,11 @@ const SWIPE_DURATION = 200; * possible to swipe */ const ON_MOUNT_BOUNCE_DELAY = 700; -const ON_MOUNT_BOUNCE_DURATION = 200; +const ON_MOUNT_BOUNCE_DURATION = 400; // Distance left of closed position to bounce back when right-swiping from closed const RIGHT_SWIPE_BOUNCE_BACK_DISTANCE = 50; +const RIGHT_SWIPE_BOUNCE_BACK_DURATION = 400; /** * Max distance of right swipe to allow (right swipes do functionally nothing). * Must be multiplied by SLOW_SPEED_SWIPE_FACTOR because gestureState.dx tracks @@ -293,11 +294,15 @@ const SwipeableRow = React.createClass({ this._animateTo(-this.props.maxSwipeDistance); }, - _animateToClosedPosition(): void { - this._animateTo(CLOSED_LEFT_POSITION); + _animateToClosedPosition(duration: number = SWIPE_DURATION): void { + this._animateTo(CLOSED_LEFT_POSITION, duration); }, - _animateBounceBack(duration: number = SWIPE_DURATION): void { + _animateToClosedPositionDuringBounce(): void { + this._animateToClosedPosition(RIGHT_SWIPE_BOUNCE_BACK_DURATION); + }, + + _animateBounceBack(duration: number): void { /** * When swiping right, we want to bounce back past closed position on release * so users know they should swipe right to get content. @@ -305,7 +310,7 @@ const SwipeableRow = React.createClass({ this._animateTo( -RIGHT_SWIPE_BOUNCE_BACK_DISTANCE, duration, - this._animateToClosedPosition, + this._animateToClosedPositionDuringBounce, ); }, @@ -330,7 +335,7 @@ const SwipeableRow = React.createClass({ if (this._isSwipingRightFromClosed(gestureState)) { this.props.onOpen(); - this._animateBounceBack(); + this._animateBounceBack(RIGHT_SWIPE_BOUNCE_BACK_DURATION); } else if (this._shouldAnimateRemainder(gestureState)) { if (horizontalDistance < 0) { // Swiped left