@@ -15,6 +15,7 @@ import {
1515
1616import { useHaptics , useStableCallbackValue } from '../../hooks' ;
1717import type {
18+ Dimensions ,
1819 DragContextType ,
1920 OverDrag ,
2021 SortableCallbacks ,
@@ -233,32 +234,30 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
233234 (
234235 touch : TouchData ,
235236 key : string ,
236- activationAnimationProgress : SharedValue < number > ,
237- fail : ( ) => void
237+ position : Vector ,
238+ dimensions : Dimensions ,
239+ activationAnimationProgress : SharedValue < number >
238240 ) => {
239241 'worklet' ;
240- const itemPosition = itemPositions . value [ key ] ;
241- const dimensions = itemDimensions . value [ key ] ;
242242 const containerMeasurements = measure ( containerRef ) ;
243243
244- if ( ! itemPosition || ! dimensions || ! containerMeasurements ) {
245- fail ( ) ;
244+ if ( ! position || ! dimensions || ! containerMeasurements ) {
246245 return ;
247246 }
248247
249248 activeAnimationProgress . value = 0 ;
250249 activeItemDropped . value = false ;
251250 prevActiveItemKey . value = activeItemKey . value ;
252251 activeItemKey . value = key ;
253- activeItemPosition . value = itemPosition ;
254- activeItemDimensions . value = itemDimensions . value [ key ] ?? null ;
252+ activeItemPosition . value = position ;
253+ activeItemDimensions . value = dimensions ;
255254 dragStartIndex . value = keyToIndex . value [ key ] ?? - 1 ;
256255 activationState . value = DragActivationState . ACTIVE ;
257256
258257 updateLayer ?.( LayerState . FOCUSED ) ;
259258 updateStartScrollOffset ?.( ) ;
260259
261- let touchedItemPosition = itemPosition ;
260+ let touchedItemPosition = position ;
262261
263262 // We need to update the custom handle measurements if the custom handle
264263 // is used (touch position is relative to the handle in this case)
@@ -279,8 +278,8 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
279278 touchPosition . value = { x : touchX , y : touchY } ;
280279 dragStartTouchPosition . value = touchPosition . value ;
281280 dragStartItemTouchOffset . value = {
282- x : touchX - itemPosition . x ,
283- y : touchY - itemPosition . y
281+ x : touchX - position . x ,
282+ y : touchY - position . y
284283 } ;
285284
286285 const hasInactiveAnimation =
@@ -319,8 +318,6 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
319318 inactiveItemOpacity ,
320319 inactiveItemScale ,
321320 indexToKey ,
322- itemDimensions ,
323- itemPositions ,
324321 keyToIndex ,
325322 prevActiveItemKey ,
326323 stableOnDragStart ,
@@ -370,7 +367,21 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
370367 if ( absoluteLayoutState . value !== AbsoluteLayoutState . COMPLETE ) {
371368 return ;
372369 }
373- handleDragStart ( touch , key , activationAnimationProgress , fail ) ;
370+
371+ const position = itemPositions . value [ key ] ;
372+ const dimensions = itemDimensions . value [ key ] ;
373+
374+ if ( ! position || ! dimensions ) {
375+ return ;
376+ }
377+
378+ handleDragStart (
379+ touch ,
380+ key ,
381+ position ,
382+ dimensions ,
383+ activationAnimationProgress
384+ ) ;
374385 activate ( ) ;
375386 } , dragActivationDelay . value ) ;
376387 } ,
@@ -382,6 +393,8 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
382393 currentTouch ,
383394 dragActivationDelay ,
384395 handleDragStart ,
396+ itemDimensions ,
397+ itemPositions ,
385398 measureContainer ,
386399 sortEnabled ,
387400 touchStartTouch
0 commit comments