Skip to content

Comments

Extract drag detection logic to interface#71

Merged
Calvin-LL merged 4 commits intoCalvin-LL:mainfrom
toasterofbread:extract-drag-detection
Jun 7, 2025
Merged

Extract drag detection logic to interface#71
Calvin-LL merged 4 commits intoCalvin-LL:mainfrom
toasterofbread:extract-drag-detection

Conversation

@toasterofbread
Copy link
Contributor

@toasterofbread toasterofbread commented Feb 4, 2025

Currently, only two hardcoded types of dragging (press and long press) are supported by this library.

This PR adds an interface, DragGestureDetector, which is responsible for handling drag detection via PointerInputScope. The interface is taken as a parameter in drag handle functions such as draggableHandle, allowing the user to override the behaviour. This is useful for applications that wish to use non-standard drag detection, such as dragging with middle click or waiting for a long press using a specific length.

API changes (let me know if you'd rather these were reverted):

  • draggableHandle methods now have a dragGestureDetector parameter in the last position (with a default value)
  • The onDragStarted and onDragStopped parameters of ReorderableScope.draggableHandle are no longer suspending and do not have CoroutineScope as a receiver

The longPressDraggableHandle API is kept the same, but now just calls draggableHandle with DragGestureDetector.LongPress as the dragGestureDetector.

@Calvin-LL Calvin-LL merged commit b7e256a into Calvin-LL:main Jun 7, 2025
@Calvin-LL
Copy link
Owner

thank you and sorry for the long wait

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

Successfully merging this pull request may close these issues.

2 participants