Skip to content

Commit 9fac5a2

Browse files
committed
fix: medium priority bug fixes
- Fix gorhom#2640: INITIAL_POSITION now uses Math.max(SCREEN_HEIGHT, WINDOW_HEIGHT) to handle web viewport resizing - Fix gorhom#2533: Account for scrollableContentOffsetY when calculating destinationPoint to fix scroll jumpy issue; change map to forEach for biome compliance
1 parent 22e6b02 commit 9fac5a2

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/components/bottomSheet/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
KEYBOARD_BLUR_BEHAVIOR,
44
KEYBOARD_INPUT_MODE,
55
SCREEN_HEIGHT,
6+
WINDOW_HEIGHT,
67
} from '../../constants';
78

89
// default values
@@ -31,7 +32,7 @@ const INITIAL_CONTAINER_OFFSET = {
3132
right: 0,
3233
};
3334
const INITIAL_HANDLE_HEIGHT = -999;
34-
const INITIAL_POSITION = SCREEN_HEIGHT;
35+
const INITIAL_POSITION = Math.max(SCREEN_HEIGHT, WINDOW_HEIGHT);
3536

3637
// accessibility
3738
const DEFAULT_ACCESSIBLE = true;

src/hooks/useGestureEventsHandlersDefault.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ const INITIAL_CONTEXT: GestureEventContextType = {
3333

3434
const dismissKeyboard = Keyboard.dismiss;
3535

36-
// biome-ignore lint: to be addressed!
3736
const resetContext = (context: any) => {
3837
'worklet';
39-
Object.keys(context).map(key => {
38+
Object.keys(context).forEach(key => {
4039
context[key] = undefined;
4140
});
4241
};
@@ -341,11 +340,22 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
341340
snapPoints.unshift(animatedClosedPosition.value);
342341
}
343342

343+
const wasGestureHandledByScrollView =
344+
source === GESTURE_SOURCE.CONTENT &&
345+
animatedScrollableContentOffsetY.value > 0;
346+
347+
let rawDestinationPosition =
348+
translationY + context.value.initialPosition;
349+
350+
if (wasGestureHandledByScrollView) {
351+
rawDestinationPosition -= animatedScrollableContentOffsetY.value;
352+
}
353+
344354
/**
345355
* calculate the destination point, using redash.
346356
*/
347357
const destinationPoint = snapPoint(
348-
translationY + context.value.initialPosition,
358+
rawDestinationPosition,
349359
velocityY,
350360
snapPoints
351361
);
@@ -358,9 +368,6 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
358368
return;
359369
}
360370

361-
const wasGestureHandledByScrollView =
362-
source === GESTURE_SOURCE.CONTENT &&
363-
animatedScrollableContentOffsetY.value > 0;
364371
/**
365372
* prevents snapping from top to middle / bottom with repeated interrupted scrolls
366373
*/

0 commit comments

Comments
 (0)