Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Pan gesture recogniser in UICollectionView interferes with drag #3

Closed
fatuhoku opened this issue May 20, 2014 · 3 comments
Closed

Pan gesture recogniser in UICollectionView interferes with drag #3

fatuhoku opened this issue May 20, 2014 · 3 comments
Labels

Comments

@fatuhoku
Copy link

Thanks for implementing the LongPressGesture recogniser some time ago.

I've been using it in the app I'm developing. I have a list of items arranged in a line. Scrolling along the view works really well. However I have found that when wanting to drag it's not robust enough.

Synopsis

User pans around on the CollectionView.
Some of the taps are registered as a long-press, because of the low duration.
Drag begins; drag view is created on some window layer.
Collection view continues with fixed inertia; stops panning; hijacks touch
Drag is NEVER COMPLETED; drag view stays on screen. Looks like a bug.

Reproduction

This occurs only sometimes, but often enough for the user to notice. The easiest way to bump up the minimmumPressDuration to something really low like 0.05f. A low duration is very important to ensure that the whole operation feels natural for the user.

        _longPressDragRecognizer = [[DNDLongPressDragRecognizer alloc] init];
        _longPressDragRecognizer.minimumPressDuration = 0.05f;
        // ...

I'll try to prepare a demo project to illustrate this problem.

@frenetisch-applaudierend
Copy link
Owner

Thanks for reporting this. It sure sounds like a bug. I'll try to take a look at it sometime next week.

@frenetisch-applaudierend
Copy link
Owner

After some investigation it seems that the UIScrollView's panGestureRecognizer somehow hijacks those touches, as you suspected.

The drag recognizer only receives a -touchesBegan: event, then the reporting stops (which is why the drag is never completed). Unfortunately, I don't see how the library could prevent this.

However there is a workaround: require the UIScrollView.panGestureRecognizer to wait until the drag recognizer failed like this:

UIScrollView *scrollView = …; // Or a sublass like UITableView or UICollectionView for that matter
UIGestureRecognizer *dragRecognizer = …;

[scrollView.panGestureRecognizer requireGestureRecognizerToFail:dragRecognizer];

I updated the example code to include this workaround.

@fatuhoku
Copy link
Author

Nice one, I'll try it now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants