@@ -23,13 +23,11 @@ import { floatingPointEquals } from '../utilities';
2323type GestureEventContextType = {
2424 initialPosition : number ;
2525 initialKeyboardState : KEYBOARD_STATE ;
26- isScrollablePositionLocked : boolean ;
2726} ;
2827
2928const INITIAL_CONTEXT : GestureEventContextType = {
3029 initialPosition : 0 ,
3130 initialKeyboardState : KEYBOARD_STATE . UNDETERMINED ,
32- isScrollablePositionLocked : false ,
3331} ;
3432
3533const dismissKeyboard = Keyboard . dismiss ;
@@ -59,6 +57,7 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
5957 overDragResistanceFactor,
6058 isInTemporaryPosition,
6159 isScrollableRefreshable,
60+ isPanGestureMoving,
6261 animateToPosition,
6362 stopAnimation,
6463 } = useBottomSheetInternal ( ) ;
@@ -70,8 +69,11 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
7069
7170 //#region gesture methods
7271 const handleOnBegin : GestureEventHandlerCallbackType = useWorkletCallback (
73- function handleOnBegin ( __ , _ ) { } ,
74- [ ]
72+ function handleOnBegin ( __ , _ ) {
73+ // touching screen
74+ isPanGestureMoving . value = true ;
75+ } ,
76+ [ isPanGestureMoving ]
7577 ) ;
7678 const handleOnStart : GestureEventHandlerCallbackType = useWorkletCallback (
7779 function handleOnStart ( __ , _ ) {
@@ -84,17 +86,6 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
8486 initialPosition : animatedPosition . value ,
8587 initialKeyboardState : animatedKeyboardState . value ,
8688 } ;
87-
88- /**
89- * if the scrollable content is scrolled, then
90- * we lock the position.
91- */
92- if ( animatedScrollableContentOffsetY . value > 0 ) {
93- context . value = {
94- ...context . value ,
95- isScrollablePositionLocked : true ,
96- } ;
97- }
9889 } ,
9990 [
10091 stopAnimation ,
@@ -145,57 +136,21 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
145136 return ;
146137 }
147138
148- /**
149- * a negative scrollable content offset to be subtracted from accumulated
150- * current position and gesture translation Y to allow user to drag the sheet,
151- * when scrollable position at the top.
152- * a negative scrollable content offset when the scrollable is not locked.
153- */
154- const negativeScrollableContentOffset =
155- ( floatingPointEquals ( context . value . initialPosition , highestSnapPoint ) &&
156- source === GESTURE_SOURCE . CONTENT ) ||
157- ! context . value . isScrollablePositionLocked
158- ? animatedScrollableContentOffsetY . value * - 1
159- : 0 ;
160-
161139 /**
162140 * an accumulated value of starting position with gesture translation y.
163141 */
164142 const draggedPosition = context . value . initialPosition + translationY ;
165143
166- /**
167- * an accumulated value of dragged position and negative scrollable content offset,
168- * this will insure locking sheet position when user is scrolling the scrollable until,
169- * they reach to the top of the scrollable.
170- */
171- const accumulatedDraggedPosition =
172- draggedPosition + negativeScrollableContentOffset ;
173-
174144 /**
175145 * a clamped value of the accumulated dragged position, to insure keeping the dragged
176146 * position between the highest and lowest snap points.
177147 */
178148 const clampedPosition = clamp (
179- accumulatedDraggedPosition ,
149+ draggedPosition ,
180150 highestSnapPoint ,
181151 lowestSnapPoint
182152 ) ;
183153
184- /**
185- * if scrollable position is locked and the animated position
186- * reaches the highest point, then we unlock the scrollable position.
187- */
188- if (
189- context . value . isScrollablePositionLocked &&
190- source === GESTURE_SOURCE . CONTENT &&
191- floatingPointEquals ( animatedPosition . value , highestSnapPoint )
192- ) {
193- context . value = {
194- ...context . value ,
195- isScrollablePositionLocked : false ,
196- } ;
197- }
198-
199154 /**
200155 * over-drag implementation.
201156 */
@@ -227,16 +182,11 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
227182
228183 if (
229184 source === GESTURE_SOURCE . CONTENT &&
230- draggedPosition + negativeScrollableContentOffset > lowestSnapPoint
185+ draggedPosition > lowestSnapPoint
231186 ) {
232187 const resistedPosition =
233188 lowestSnapPoint +
234- Math . sqrt (
235- 1 +
236- ( draggedPosition +
237- negativeScrollableContentOffset -
238- lowestSnapPoint )
239- ) *
189+ Math . sqrt ( 1 + ( draggedPosition - lowestSnapPoint ) ) *
240190 overDragResistanceFactor ;
241191 animatedPosition . value = resistedPosition ;
242192 return ;
@@ -402,8 +352,9 @@ export const useGestureEventsHandlers: GestureEventsHandlersHookType = () => {
402352 const handleOnFinalize : GestureEventHandlerCallbackType = useWorkletCallback (
403353 function handleOnFinalize ( ) {
404354 resetContext ( context ) ;
355+ isPanGestureMoving . value = false ;
405356 } ,
406- [ context ]
357+ [ context , isPanGestureMoving ]
407358 ) ;
408359 //#endregion
409360
0 commit comments