Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"squishy" drag 'n' drop of pieces already on the board #3

Open
csells opened this issue Jul 29, 2020 · 3 comments
Open

"squishy" drag 'n' drop of pieces already on the board #3

csells opened this issue Jul 29, 2020 · 3 comments

Comments

@csells
Copy link
Collaborator

csells commented Jul 29, 2020

it feels like we're using touch-based d'n'd instead of mouse-based d'n'd which is intrinsically "squishy" as you have to move 5-10 pixels before a drag operation is registered and the piece is first moved.

@deniza
Copy link

deniza commented Aug 30, 2020

@csells this is a general problem about Draggables. You can use a slightly modified version of Draggable to solve this issue. Below is a ZeroDelayDraggableClass I am using which prevents "touch -> drag" delay you mentioned.

class ZeroDelayDraggable extends Draggable<dynamic> {

  _ZeroDelayDraggable({Tile dynamic, int maxSimultaneousDrags, Widget child, Widget feedback, DragAnchor dragAnchor, Widget childWhenDragging, VoidCallback onDragStarted, DraggableCanceledCallback onDraggableCanceled, DragEndCallback onDragEnd})
    : super(data: data, maxSimultaneousDrags: maxSimultaneousDrags, child: child, feedback: feedback, dragAnchor: dragAnchor, childWhenDragging: childWhenDragging, onDragStarted: onDragStarted, onDraggableCanceled: onDraggableCanceled, onDragEnd: onDragEnd);

  @override
  MultiDragGestureRecognizer<MultiDragPointerState> createRecognizer(GestureMultiDragStartCallback onStart) {
    return DelayedMultiDragGestureRecognizer(delay: Duration.zero)..onStart = onStart;
  }

}

@csells
Copy link
Collaborator Author

csells commented Aug 30, 2020

Interesting. Can the same technique be used with a GestureDetector?

@deniza
Copy link

deniza commented Aug 31, 2020

There will be a delay if you use multiple gesture recognizers on top of each other. Here we got 2 objects fighting for gesture events. One is game board, one is the draggable on the game board. If you have only one gesture detecting widget, for example a SingleChildScrollView, there will be no delay recognizing the drag gesture.

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

No branches or pull requests

2 participants