Skip to content

Commit

Permalink
feat: added Reanimated v2 compatibility (#15 by @sa8ab) (#24)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gorhom and sa8ab committed Aug 21, 2020
1 parent d68ff63 commit f38c6c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Animated, {
and,
// concat,
greaterThan,
interpolate,
Extrapolate,
set,
// defined,
Expand Down Expand Up @@ -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({
Expand Down
8 changes: 7 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit f38c6c6

Please sign in to comment.