From f38c6c6ff8ccdac3ee9a35c91b02a70f81d0b00b Mon Sep 17 00:00:00 2001 From: Mo Gorhom Date: Fri, 21 Aug 2020 22:29:40 +0200 Subject: [PATCH] feat: added Reanimated v2 compatibility (#15 by @sa8ab) (#24) * feat: added Reanimated v2 support (#15) * Update Easing to work with reanimated 2 * compatible with reanimated 2 * chore: updated import Easing & interpolate from reanimated Co-authored-by: sa8ab <59901734+sa8ab@users.noreply.github.com> --- src/components/bottomSheet/BottomSheet.tsx | 7 ++++++- src/constants.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index d1b3395c..4a85fe8e 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -19,7 +19,6 @@ import Animated, { and, // concat, greaterThan, - interpolate, Extrapolate, set, // defined, @@ -54,6 +53,12 @@ import type { ScrollableRef, BottomSheetMethods } from '../../types'; import type { BottomSheetProps } from './types'; import { styles } from './styles'; +const { + interpolate: interpolateV1, + interpolateNode: interpolateV2, +} = require('react-native-reanimated'); +const interpolate = interpolateV2 || interpolateV1; + type BottomSheet = BottomSheetMethods; Animated.addWhitelistedUIProps({ diff --git a/src/constants.ts b/src/constants.ts index cc6c2e64..1bc765d0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,10 @@ -import Animated, { Easing } from 'react-native-reanimated'; +import Animated from 'react-native-reanimated'; + +const { + Easing: EasingV1, + EasingNode: EasingV2, +} = require('react-native-reanimated'); +const Easing = EasingV2 || EasingV1; export const DEFAULT_ANIMATION_EASING: Animated.EasingFunction = Easing.out( Easing.back(0.75)