From 9039591ac99850b778ab5b827f92da1e0042bcbd Mon Sep 17 00:00:00 2001 From: Mo Gorhom Date: Thu, 21 Jan 2021 23:05:39 +0100 Subject: [PATCH] fix: removed onScroll event from BottomSheetScrollView (#225) --- src/components/bottomSheet/BottomSheet.tsx | 9 ++++----- src/components/flatList/FlatList.tsx | 6 +++--- src/components/scrollView/ScrollView.tsx | 7 +++---- src/components/sectionList/SectionList.tsx | 6 +++--- src/contexts/internal.ts | 4 ++-- src/hooks/useScrollableInternal.ts | 4 ++-- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index c337874b5..bdb10400f 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -629,11 +629,10 @@ const BottomSheetComponent = forwardRef( )} {/* */} + values={{ + position, + }} + /> */} ); diff --git a/src/components/flatList/FlatList.tsx b/src/components/flatList/FlatList.tsx index bff49976c..450c3261a 100644 --- a/src/components/flatList/FlatList.tsx +++ b/src/components/flatList/FlatList.tsx @@ -40,7 +40,7 @@ const BottomSheetFlatListComponent = forwardRef( // hooks const { scrollableRef, - handleScrollEvent, + handleOnBeginDragEvent, handleSettingScrollable, } = useScrollableInternal('FlatList'); const { @@ -73,8 +73,8 @@ const BottomSheetFlatListComponent = forwardRef( overScrollMode="never" bounces={false} decelerationRate={decelerationRate} - scrollEventThrottle={1} - onScrollBeginDrag={handleScrollEvent} + scrollEventThrottle={16} + onScrollBeginDrag={handleOnBeginDragEvent} /> diff --git a/src/components/scrollView/ScrollView.tsx b/src/components/scrollView/ScrollView.tsx index 63a5b5633..795a98d78 100644 --- a/src/components/scrollView/ScrollView.tsx +++ b/src/components/scrollView/ScrollView.tsx @@ -40,7 +40,7 @@ const BottomSheetScrollViewComponent = forwardRef( // hooks const { scrollableRef, - handleScrollEvent, + handleOnBeginDragEvent, handleSettingScrollable, } = useScrollableInternal('ScrollView'); const { @@ -71,9 +71,8 @@ const BottomSheetScrollViewComponent = forwardRef( overScrollMode="never" bounces={false} decelerationRate={decelerationRate} - scrollEventThrottle={1} - onScroll={handleScrollEvent} - onScrollBeginDrag={handleScrollEvent} + scrollEventThrottle={16} + onScrollBeginDrag={handleOnBeginDragEvent} /> diff --git a/src/components/sectionList/SectionList.tsx b/src/components/sectionList/SectionList.tsx index e3b0b2222..3343746d8 100644 --- a/src/components/sectionList/SectionList.tsx +++ b/src/components/sectionList/SectionList.tsx @@ -40,7 +40,7 @@ const BottomSheetSectionListComponent = forwardRef( // hooks const { scrollableRef, - handleScrollEvent, + handleOnBeginDragEvent, handleSettingScrollable, } = useScrollableInternal('SectionList'); const { @@ -72,8 +72,8 @@ const BottomSheetSectionListComponent = forwardRef( overScrollMode="never" bounces={false} decelerationRate={decelerationRate} - scrollEventThrottle={1} - onScrollBeginDrag={handleScrollEvent} + scrollEventThrottle={16} + onScrollBeginDrag={handleOnBeginDragEvent} /> diff --git a/src/contexts/internal.ts b/src/contexts/internal.ts index 553dc020d..3d20ac7f3 100644 --- a/src/contexts/internal.ts +++ b/src/contexts/internal.ts @@ -1,7 +1,7 @@ import { createContext, Ref, RefObject } from 'react'; -import { TapGestureHandler, State } from 'react-native-gesture-handler'; +import type { TapGestureHandler, State } from 'react-native-gesture-handler'; import type Animated from 'react-native-reanimated'; -import { Scrollable, ScrollableRef } from '../types'; +import type { Scrollable, ScrollableRef } from '../types'; export type BottomSheetInternalContextType = { enableContentPanningGesture: boolean; diff --git a/src/hooks/useScrollableInternal.ts b/src/hooks/useScrollableInternal.ts index ef5fe4831..61bfd8da2 100644 --- a/src/hooks/useScrollableInternal.ts +++ b/src/hooks/useScrollableInternal.ts @@ -19,7 +19,7 @@ export const useScrollableInternal = (type: ScrollableType) => { } = useBottomSheetInternal(); // callbacks - const handleScrollEvent = useMemo( + const handleOnBeginDragEvent = useMemo( () => event([ { @@ -65,7 +65,7 @@ export const useScrollableInternal = (type: ScrollableType) => { return { scrollableRef, - handleScrollEvent, + handleOnBeginDragEvent, handleSettingScrollable, }; };