# AnimationScope

# AnimationScope

Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation)  
[View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+class:androidx.compose.animation.core.AnimationScope)  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)
Common/All
  - Cmn  

  ```
  class AnimationScope<T : Any?, V : AnimationVector>
  ```

*** ** * ** ***

[AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) provides all the animation related info specific to an animation run. An [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) will be accessible during an animation.  

|                                                                                                                             See also                                                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [animateTo](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)) |   |

## Summary

|                                                  ### Public functions                                                   |
|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [cancelAnimation](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation())`()` Cancels the animation that this [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) corresponds to.                                                                                                                                                                                                                                     | Cmn |
| [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState)`<T, V>` | [toAnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#toAnimationState())`()` Creates an [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) that populates all the fields in [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) from [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope). | Cmn |

|                                                   ### Public properties                                                   |
|---------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                             | [finishedTimeNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#finishedTimeNanos()) The time when the animation finished successfully in the System.nanoTime timebase.                                                                                                                                                                                                                                                                          | Cmn |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                       | [isRunning](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#isRunning()) Indicates whether the animation is currently running.                                                                                                                                                                                                                                                                                                                       | Cmn |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                             | [lastFrameTimeNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#lastFrameTimeNanos()) Last frame time of the animation.                                                                                                                                                                                                                                                                                                                         | Cmn |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                             | [startTimeNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#startTimeNanos()) Start time of the animation in the System.nanoTime timebase.                                                                                                                                                                                                                                                                                                      | Cmn |
| `T`                                                                                                                       | [targetValue](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#targetValue()) Target value of the animation.                                                                                                                                                                                                                                                                                                                                          | Cmn |
| [TwoWayConverter](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter)`<T, V>` | [typeConverter](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#typeConverter()) [TwoWayConverter](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter) to convert type [T](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) from and to [AnimationVector](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector). | Cmn |
| `T`                                                                                                                       | [value](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#value()) Current value of the [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope).                                                                                                                                                                                                                                               | Cmn |
| `T`                                                                                                                       | [velocity](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#velocity()) Velocity of type [T](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope), converted from [velocityVector](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#velocityVector()).                                                                                                         | Cmn |
| `V`                                                                                                                       | [velocityVector](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#velocityVector()) Current velocity vector of the [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope).                                                                                                                                                                                                                   | Cmn |

## Public functions

### cancelAnimation

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
fun cancelAnimation(): Unit
```

Cancels the animation that this [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) corresponds to. The scope will not be updated any more after [cancelAnimation](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#cancelAnimation()) is called.  

### toAnimationState

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
fun toAnimationState(): AnimationState<T, V>
```

Creates an [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) that populates all the fields in [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) from [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope).

## Public properties

### finishedTimeNanos

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val finishedTimeNanos: Long
```

The time when the animation finished successfully in the System.nanoTime timebase.

If the animation has never finished (i.e. currently running, interrupted, or never started), this will be [AnimationConstants.UnspecifiedTime](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()), unless specified otherwise in [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) constructor.  

### isRunning

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val isRunning: Boolean
```

Indicates whether the animation is currently running.  

### lastFrameTimeNanos

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val lastFrameTimeNanos: Long
```

Last frame time of the animation.

If the animation has never started, this will be [AnimationConstants.UnspecifiedTime](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#UnspecifiedTime()), unless specified otherwise in the [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState) constructor. [lastFrameTimeNanos](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#lastFrameTimeNanos()) is the frame time when the animation is last updated, in the System.nanoTime timebase. It is also used for starting a sequential animation in [AnimationState.animateTo](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.AnimationState).animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean,kotlin.Function1)). This allows the sequential animation to set its start time to when the previous animation is interrupted or finished.  

### startTimeNanos

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val startTimeNanos: Long
```

Start time of the animation in the System.nanoTime timebase.  

### targetValue

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val targetValue: T
```

Target value of the animation.  

### typeConverter

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val typeConverter: TwoWayConverter<T, V>
```

[TwoWayConverter](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter) to convert type [T](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope) from and to [AnimationVector](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector).  

### value

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val value: T
```

Current value of the [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope).  

### velocity

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val velocity: T
```

Velocity of type [T](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope), converted from [velocityVector](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope#velocityVector()).  

### velocityVector

Cmn  
Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)  

```
val velocityVector: V
```

Current velocity vector of the [AnimationScope](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationScope).