Skip to content

Commit db586d7

Browse files
authored
fix: Prevent auto scroll from over scrolling content container (#484)
## Description This PR is an another fix to the issue that I attempted to fix in the #473 PR. It seems that the issue still occurred as the `measure` function and the `scrollOffset` value received from the `useScrollOffset` weren't updated in sync.
1 parent 3e9e550 commit db586d7

8 files changed

Lines changed: 220 additions & 284 deletions

File tree

example/app/src/examples/SortableGrid/features/AutoScrollExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useBottomNavBarHeight } from '@/providers';
1818
import { colors, spacing, style } from '@/theme';
1919
import { getItems } from '@/utils';
2020

21-
const MANY_ITEMS = getItems(21);
21+
const MANY_ITEMS = getItems(30);
2222
const FEW_ITEMS = getItems(6);
2323

2424
const LIST_ITEM_SECTIONS = ['List item 1', 'List item 2', 'List item 3'];

packages/react-native-sortables/src/components/SortableFlex.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ function SortableFlexComponent({
236236
{...rest}
237237
containerStyle={[baseContainerStyle, animatedContainerStyle]}
238238
itemStyle={styles.styleOverride}
239-
onLayout={runOnUI((w, h) => {
240-
handleContainerMeasurement(w, h);
241-
})}
239+
onLayout={runOnUI(handleContainerMeasurement)}
242240
/>
243241
);
244242
}

packages/react-native-sortables/src/components/shared/SortableContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ export default function SortableContainer({
115115
<AnimatedOnLayoutView
116116
ref={containerRef}
117117
style={[containerStyle, innerContainerStyle]}
118-
onLayout={({ nativeEvent: { layout } }) => {
119-
onLayout(layout.width, layout.height);
120-
}}>
118+
onLayout={({ nativeEvent: { layout } }) =>
119+
onLayout(layout.width, layout.height)
120+
}>
121121
<ItemsOutlet
122122
itemEntering={itemEntering}
123123
itemExiting={itemExiting}

0 commit comments

Comments
 (0)