# 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)

*** ** * ** ***


```
public 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 `https://developer.android.com/reference/android/view/MotionEvent.html#AXIS_SCROLL`.

The client should call `https://developer.android.com/reference/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 |
|---|
| `https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingController#DifferentialMotionFlingController(android.content.Context,androidx.core.view.DifferentialMotionFlingTarget)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingTarget target )` Constructs an instance for a given `https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingTarget`. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingController#onMotionEvent(android.view.MotionEvent,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html event, int axis)` 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)

```
public DifferentialMotionFlingController(
    @NonNull Context context,
    @NonNull DifferentialMotionFlingTarget target
)
```

Constructs an instance for a given `https://developer.android.com/reference/androidx/core/view/DifferentialMotionFlingTarget`.

## Public methods

### onMotionEvent

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

```
public void onMotionEvent(@NonNull MotionEvent event, int axis)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html event` | the `https://developer.android.com/reference/android/view/MotionEvent.html` being reported. |
| `int axis` | the axis being processed by the target View. |