{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DraggableState

public interface DraggableState

Known direct subclasses
SliderState

Class that holds information about Slider's active range.


State of draggable. Allows for a granular control of how deltas are consumed by the user as well as to write custom drag methods using drag suspend function.

Summary

Public methods

abstract void
dispatchRawDelta(float delta)

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

abstract void
drag(
    @NonNull MutatePriority dragPriority,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull DragScopeUnit> block
)

Call this function to take control of drag logic.

Public methods

dispatchRawDelta

abstract void dispatchRawDelta(float delta)

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

NOTE: unlike drag, dispatching any delta with this method will bypass scrolling of any priority. This method will also ignore reverseDirection and other parameters set in draggable.

This method is used internally for low level operations, allowing implementers of DraggableState influence the consumption as suits them, e.g. introduce nested scrolling. Manually dispatching delta via this method will likely result in a bad user experience, you must prefer drag method over this one.

Parameters
float delta

amount of scroll dispatched in the nested drag process

drag

abstract void drag(
    @NonNull MutatePriority dragPriority,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull DragScopeUnit> block
)

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a drag block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.

If drag is called from elsewhere with the dragPriority higher or equal to ongoing drag, ongoing drag will be canceled.

Parameters
@NonNull MutatePriority dragPriority

of the drag operation

@ExtensionFunctionType @NonNull SuspendFunction1<@NonNull DragScopeUnit> block

to perform drag in