Skip to content

Commit 57d8ad4

Browse files
authored
fix(ios): another crash while long pressing to reorder
1 parent 8d20a52 commit 57d8ad4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/collectionview/index.ios.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,20 @@ export class CollectionView extends CollectionViewBase {
342342
case UIGestureRecognizerState.Began: {
343343
let point = gesture.locationInView(collectionView);
344344
const selectedIndexPath = collectionView.indexPathForItemAtPoint(point);
345-
const view = this.getViewForItemAtIndex(selectedIndexPath.row);
346-
if (view) {
347-
const size = view.nativeViewProtected.bounds.size;
348-
point = gesture.locationInView(view.nativeViewProtected);
349-
this.draggingStartDelta = [point.x - size.width / 2, point.y - size.height / 2];
345+
if (selectedIndexPath) {
346+
const view = this.getViewForItemAtIndex(selectedIndexPath.row);
347+
if (view) {
348+
const size = view.nativeViewProtected.bounds.size;
349+
point = gesture.locationInView(view.nativeViewProtected);
350+
this.draggingStartDelta = [point.x - size.width / 2, point.y - size.height / 2];
351+
}
352+
collectionView.beginInteractiveMovementForItemAtIndexPath(selectedIndexPath);
353+
} else {
354+
// disable and enable to cancel the current gesture
355+
gesture.enabled = false;
356+
gesture.enabled = true;
350357
}
351-
collectionView.beginInteractiveMovementForItemAtIndexPath(selectedIndexPath);
358+
352359
break;
353360
}
354361
case UIGestureRecognizerState.Changed: {

0 commit comments

Comments
 (0)