anchoredDrag
public suspend fun anchoredDrag(
dragPriority: MutatePriority = MutatePriority.Default,
block: suspend AnchoredDragScope.(anchors: DraggableAnchors<T>) -> Unit,
)
Call this function to take control of drag logic and perform anchored drag with the latest anchors.
All actions that change the offset of this AnchoredDraggableState must be performed within an anchoredDrag block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.
If anchoredDrag is called from elsewhere with the dragPriority higher or equal to ongoing drag, the ongoing drag will be cancelled.
If the anchors change while the block is being executed, it will be cancelled and re-executed with the latest anchors and target. This allows you to target the correct state.
Parameters
| dragPriority | of the drag operation |
| block | perform anchored drag given the current anchor provided |
anchoredDrag
public suspend fun anchoredDrag(
targetValue: T,
dragPriority: MutatePriority = MutatePriority.Default,
block: suspend AnchoredDragScope.(anchor: DraggableAnchors<T>, targetValue: T) -> Unit,
)
Call this function to take control of drag logic and perform anchored drag with the latest anchors and target.
All actions that change the offset of this AnchoredDraggableState must be performed within an anchoredDrag block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.
This overload allows the caller to hint the target value that this anchoredDrag is intended to arrive to. This will set AnchoredDraggableState.targetValue to provided value so consumers can reflect it in their UIs.
If the anchors or AnchoredDraggableState.targetValue change while the block is being executed, it will be cancelled and re-executed with the latest anchors and target. This allows you to target the correct state.
If anchoredDrag is called from elsewhere with the dragPriority higher or equal to ongoing drag, the ongoing drag will be cancelled.
Parameters
| targetValue | hint the target value that this anchoredDrag is intended to arrive to |
| dragPriority | of the drag operation |
| block | perform anchored drag given the current anchor provided |