From 626778e1e54db2412ff94535ac24c12df4ab7523 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Tue, 16 Apr 2019 15:14:39 +0200 Subject: [PATCH] Refine Bottom Sheets in/out transition (#14831) As specified in https://github.com/wordpress-mobile/gutenberg-mobile/issues/595 I did my best to adjust to the specs there, and for the most part the animations matches what was requested. One limitation is that due to how react-native-modal is implemented, we don't know the view's height when it's about to be presented, and so it starts the "slide in" animation not from the bottom edge, but from a lower point, since it uses the window height to displace the view and not the view's height. The result is an animation that appears slower than specified, since the view has to traverse a longer distance in the same time, and there is a delay before the view starts appearing. This is mildly annoying, but I could not find a way to make it work without rewriting react-native-modal. --- .../mobile/bottom-sheet/index.native.js | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/mobile/bottom-sheet/index.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/index.native.js index 6ec1ab2632781..fbda22cc7aa66 100644 --- a/packages/block-editor/src/components/mobile/bottom-sheet/index.native.js +++ b/packages/block-editor/src/components/mobile/bottom-sheet/index.native.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { Text, View, Platform, PanResponder, Dimensions } from 'react-native'; +import { Text, View, Platform, PanResponder, Dimensions, Easing } from 'react-native'; import Modal from 'react-native-modal'; import SafeArea from 'react-native-safe-area'; @@ -94,14 +94,39 @@ class BottomSheet extends Component { ); + const { height } = Dimensions.get( 'window' ); + const easing = Easing.bezier( 0.450, 0.000, 0.160, 1.020 ); + + const animationIn = { + easing, + from: { + translateY: height, + }, + to: { + translateY: 0, + }, + }; + + const animationOut = { + easing, + from: { + translateY: 0, + }, + to: { + translateY: height, + }, + }; + return (