Skip to content
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

feat: allow dynamic snap points #81

Merged
merged 12 commits into from
Nov 27, 2020
Prev Previous commit
Next Next commit
chore: updated content wrapper
  • Loading branch information
gorhom committed Nov 21, 2020
commit fb3463995e5ec841b3bec3945778aa670a05e3dd
12 changes: 9 additions & 3 deletions src/components/contentWrapper/ContentWrapper.android.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import React, { forwardRef, memo } from 'react';
import isEqual from 'lodash.isequal';
import { TapGestureHandler } from 'react-native-gesture-handler';
import Animated from 'react-native-reanimated';
import type { BottomSheetContentWrapperProps } from './types';

const ContentWrapperComponent = forwardRef<
TapGestureHandler,
BottomSheetContentWrapperProps
>(
(
{ children, initialMaxDeltaY, onGestureEvent, onHandlerStateChange },
{ style, children, onLayout, onGestureEvent, onHandlerStateChange },
ref
) => {
return (
<TapGestureHandler
ref={ref}
maxDurationMs={1000000}
maxDeltaY={initialMaxDeltaY}
shouldCancelWhenOutside={false}
onGestureEvent={onGestureEvent}
onHandlerStateChange={onHandlerStateChange}
>
{children}
<Animated.View
onLayout={onLayout}
pointerEvents="box-none"
style={style}
>
{children}
</Animated.View>
</TapGestureHandler>
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/contentWrapper/ContentWrapper.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ const ContentWrapperComponent = forwardRef<
BottomSheetContentWrapperProps
>(
(
{ children, initialMaxDeltaY, style, onGestureEvent, onHandlerStateChange },
{ style, children, onLayout, onGestureEvent, onHandlerStateChange },
ref
) => {
return (
<TapGestureHandler
ref={ref}
maxDurationMs={1000000}
maxDeltaY={initialMaxDeltaY}
shouldCancelWhenOutside={false}
onGestureEvent={onGestureEvent}
onHandlerStateChange={onHandlerStateChange}
>
<Animated.View pointerEvents="box-none" style={style}>
<Animated.View
onLayout={onLayout}
pointerEvents="box-none"
style={style}
>
{children}
</Animated.View>
</TapGestureHandler>
Expand Down
6 changes: 3 additions & 3 deletions src/components/contentWrapper/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { RefAttributes } from 'react';
import type { StyleProp, ViewStyle } from 'react-native';
import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
import type { TapGestureHandler } from 'react-native-gesture-handler';

export type BottomSheetContentWrapperProps = {
children: React.ReactNode;
initialMaxDeltaY: number;
style: StyleProp<ViewStyle>;
children: React.ReactNode;
onLayout?: ViewProps['onLayout'];
onHandlerStateChange: (...args: any[]) => void;
onGestureEvent: (...args: any[]) => void;
};
Expand Down