AnimatedFloatDragController
class AnimatedFloatDragController : DragValueController
kotlin.Any | |
↳ | androidx.ui.foundation.animation.AnimatedFloatDragController |
Controller that proxy all dragging events to AnimatedFloat and FlingConfig
It makes it possible to have animation support for Draggable composable as well as to have fling animation after drag has ended, which is defined by FlingConfig
Summary
Public constructors |
|
---|---|
<init>(initialValue: Float, flingConfig: FlingConfig?) Construct controller that creates and owns AnimatedFloat instance |
|
<init>(animatedFloat: AnimatedFloat, flingConfig: FlingConfig? = null) Controller that proxy all dragging events to AnimatedFloat and FlingConfig |
Public methods |
|
---|---|
Unit |
Perform drag to target on controlled value |
Unit |
Perform finishing activities when drag has ended with given velocity |
Unit |
Set bounds for controlled value |
Properties |
|
---|---|
AnimatedFloat |
instance of AnimatedFloat to control |
Float |
Current Float value of controlled value |
Boolean |
whether or not this controller should update value on drag / fling events |
Public constructors
<init>
AnimatedFloatDragController(
initialValue: Float,
flingConfig: FlingConfig?)
Construct controller that creates and owns AnimatedFloat instance
Parameters | |
---|---|
initialValue | initial value for AnimatedFloat to set it up |
flingConfig | sets behavior of the fling after drag has ended. Default is null, which means no fling will occur no matter the velocity |
<init>
AnimatedFloatDragController(
animatedFloat: AnimatedFloat,
flingConfig: FlingConfig? = null)
Controller that proxy all dragging events to AnimatedFloat and FlingConfig
It makes it possible to have animation support for Draggable composable as well as to have fling animation after drag has ended, which is defined by FlingConfig
Parameters | |
---|---|
animatedFloat | instance of AnimatedFloat to control |
flingConfig | sets behavior of the fling after drag has ended. Default is null, which means no fling will occur no matter the velocity |
Public methods
onDrag
fun onDrag(target: Float
): Unit
Perform drag to target on controlled value
Parameters | |
---|---|
target: Float = null: Float |
the resulted position for controlled value |
onDragEnd
fun onDragEnd(
velocity: Float,
onValueSettled: (Float) -> Unit
): Unit
Perform finishing activities when drag has ended with given velocity
This is a good place to start fling or consume velocity in some other way if you need to do so.
Callback passed to this function must be called after controlled value reached it's final destination, e.g. it might be an immediate drag end or the end of the fling.
Parameters | |
---|---|
velocity: Float = null: Float |
the velocity value when drag has ended |
onValueSettled: (Float) -> Unit = null: (Float) -> Unit |
callback to call after fling has ended and controlled value settled |
setBounds
fun setBounds(
min: Float,
max: Float
): Unit
Set bounds for controlled value
Parameters | |
---|---|
min: Float = null: Float |
lower bound for dragging |
max: Float = null: Float |
upper bound for dragging |
Properties
enabled
var enabled: Boolean
whether or not this controller should update value on drag / fling events