# DifferentialMotionFlingController

# DifferentialMotionFlingController

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/DifferentialMotionFlingController.java+class:androidx.core.view.DifferentialMotionFlingController)  
Added in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingController "View this page in Java")

<br />

```
class DifferentialMotionFlingController
```

<br />

*** ** * ** ***

Controller differential motion flings.

**Differential motion** here refers to motions that report change in position instead of absolution position. For instance, differential data points of 2, -1, 5 represent: there was a movement by "2" units, then by "-1" units, then by "5" units. Examples of motions reported differentially include motions from[AXIS_SCROLL](https://developer.android.com/reference/android/view/MotionEvent.html#AXIS_SCROLL()).

The client should call[onMotionEvent](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingController#onMotionEvent(android.view.MotionEvent,int))when a differential motion event happens on the target View (that is, the View on which we want to fling), and this class processes the event to orchestrate fling.

Note that this class currently works to control fling only in one direction at a time. As such, it works independently of horizontal/vertical orientations. It requests its client to start/stop fling, and it's up to the client to choose the fling direction based on its specific internal configurations and/or preferences.

## Summary

|                                                                                                                                                                                                                                                                                                                          ### Public constructors                                                                                                                                                                                                                                                                                                                           |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DifferentialMotionFlingController](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingController#DifferentialMotionFlingController(android.content.Context,androidx.core.view.DifferentialMotionFlingTarget))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` target: `[DifferentialMotionFlingTarget](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingTarget) `)` Constructs an instance for a given[DifferentialMotionFlingTarget](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingTarget). |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onMotionEvent](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingController#onMotionEvent(android.view.MotionEvent,int))`(event: `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)`, axis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called to report when a differential motion happens on the View that's the target for fling. |

## Public constructors

### DifferentialMotionFlingController

Added in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
DifferentialMotionFlingController(
    context: Context,
    target: DifferentialMotionFlingTarget
)
```

Constructs an instance for a given[DifferentialMotionFlingTarget](https://developer.android.com/reference/kotlin/androidx/core/view/DifferentialMotionFlingTarget).  

## Public functions

### onMotionEvent

Added in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
fun onMotionEvent(event: MotionEvent, axis: Int): Unit
```

Called to report when a differential motion happens on the View that's the target for fling.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| `event: `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html) | the[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)being reported. |
| `axis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | the axis being processed by the target View.                                                           |