# FlingBehavior

# FlingBehavior

Artifact:[androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation)  
[View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/gestures/FlingBehavior.kt+class:androidx.compose.foundation.gestures.FlingBehavior)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)
Common/AllAndroid/JVM
  - Cmn  

  ```
  interface FlingBehavior
```  
Known direct subclasses  
[TargetedFlingBehavior](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/TargetedFlingBehavior)  

|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| [TargetedFlingBehavior](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/TargetedFlingBehavior) | Interface to specify fling behavior with additional information about its animation target. |

*** ** * ** ***

Interface to specify fling behavior.

When drag has ended with velocity in[scrollable](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.Modifier).scrollable(androidx.compose.foundation.gestures.ScrollableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.gestures.FlingBehavior,androidx.compose.foundation.interaction.MutableInteractionSource)),[performFling](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior#(androidx.compose.foundation.gestures.ScrollScope).performFling(kotlin.Float))is invoked to perform fling animation and update state via[ScrollScope.scrollBy](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope#scrollBy(kotlin.Float))

## Summary

|                                   ### Public functions                                    |
|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| `suspend `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [ScrollScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope)`.`[performFling](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior#(androidx.compose.foundation.gestures.ScrollScope).performFling(kotlin.Float))`(initialVelocity: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Perform settling via fling animation with given velocity and suspend until fling has finished. | Cmn |

## Public functions

### performFling

Cmn  
Artifact:[androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation)  
[View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/gestures/FlingBehavior.kt+function:performFling)  

```
suspend fun ScrollScope.performFling(initialVelocity: Float): Float
```

Perform settling via fling animation with given velocity and suspend until fling has finished.

This functions is called with[ScrollScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope)to drive the state change of the[androidx.compose.foundation.gestures.ScrollableState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState)via[ScrollScope.scrollBy](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope#scrollBy(kotlin.Float)).

This function must return correct velocity left after it is finished flinging in order to guarantee proper nested scroll support.  

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `initialVelocity: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | velocity available for fling in the orientation specified in[androidx.compose.foundation.gestures.scrollable](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.Modifier).scrollable(androidx.compose.foundation.gestures.ScrollableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.gestures.FlingBehavior,androidx.compose.foundation.interaction.MutableInteractionSource))that invoked this method. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|----------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | remaining velocity after fling operation has ended |