---
title: "animateMoveAlong"
description: "Move the trackpad along the given [curve], sending a stream of move events to get an animated
path of [durationMillis] milliseconds. The trackpad will initially be moved to the start of the
path, `curve(0)`, if it is not already there. The positions defined by the [curve] are in the
node's local coordinate system, where (0, 0) is the top left corner of the node.

Example of moving the trackpad along a curve:"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun TrackpadInjectionScope.animateMoveAlong(
    curve: (timeMillis: Long) -> Offset,
    durationMillis: Long = DefaultTrackpadGestureDurationMillis,
)
```


Move the trackpad along the given `curve`, sending a stream of move events to get an animated
path of `durationMillis` milliseconds. The trackpad will initially be moved to the start of the
path, `curve(0)`, if it is not already there. The positions defined by the `curve` are in the
node's local coordinate system, where (0, 0) is the top left corner of the node.

Example of moving the trackpad along a curve:

#### Parameters

| | |
| --- | --- |
| curve | The function that defines the position of the trackpad over time for this gesture, in the node's local coordinate system. The argument passed to the function is the time in milliseconds since the start of the animated move, and the return value is the location of the trackpad at that point in time |
| durationMillis | The duration of the gesture. By default 300 milliseconds. |




<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun MouseInjectionScope.animateMoveAlong(
    curve: (timeMillis: Long) -> Offset,
    durationMillis: Long = DefaultMouseGestureDurationMillis,
)
```


Move the mouse along the given `curve`, sending a stream of move events to get an animated path
of `durationMillis` milliseconds. The mouse will initially be moved to the start of the path,
`curve(0)`, if it is not already there. The positions defined by the `curve` are in the node's
local coordinate system, where (0, 0) is the top left corner of the node.

Example of moving the mouse along a curve:

#### Parameters

| | |
| --- | --- |
| curve | The function that defines the position of the mouse over time for this gesture, in the node's local coordinate system. The argument passed to the function is the time in milliseconds since the start of the animated move, and the return value is the location of the mouse at that point in time |
| durationMillis | The duration of the gesture. By default 300 milliseconds. |




## Code Examples
### mouseInputAnimateMoveAlong
```kotlin
fun mouseInputAnimateMoveAlong() {
    composeTestRule.onNodeWithTag("myComponent").performMouseInput {
        // Hover over the node, making a full circle with a radius of 100px
        val r = 100f
        animateMoveAlong(
            curve = {
                val angle = 2 * PI * it / 1000
                center + Offset(r * cos(angle).toFloat(), r * sin(angle).toFloat())
            },
            durationMillis = 1000L,
        )
    }
}
```
### trackpadInputAnimateMoveAlong
```kotlin
fun trackpadInputAnimateMoveAlong() {
    composeTestRule.onNodeWithTag("myComponent").performTrackpadInput {
        // Hover over the node, making a full circle with a radius of 100px
        val r = 100f
        animateMoveAlong(
            curve = {
                val angle = 2 * PI * it / 1000
                center + Offset(r * cos(angle).toFloat(), r * sin(angle).toFloat())
            },
            durationMillis = 1000L,
        )
    }
}
```

