---
title: "Animation"
description: "This interface provides a convenient way to query from an [VectorizedAnimationSpec] or
[FloatDecayAnimationSpec]: It spares the need to pass the starting conditions and in some cases
ending condition for each value or velocity query, and instead only requires the play time to be
passed for such queries.

The implementation of this interface should cache the starting conditions and ending conditions
of animations as needed.

__Note__: [Animation] does not track the lifecycle of an animation. It merely reacts to play time
change and returns the new value/velocity as a result. It can be used as a building block for
more lifecycle aware animations. In contrast, [Animatable] and [Transition] are stateful and
manage their own lifecycles."
type: "interface"
---

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


<a id='references'></a>

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



```kotlin
@JvmDefaultWithCompatibility
public interface Animation<T, V : AnimationVector>
```


This interface provides a convenient way to query from an `VectorizedAnimationSpec` or
`FloatDecayAnimationSpec`: It spares the need to pass the starting conditions and in some cases
ending condition for each value or velocity query, and instead only requires the play time to be
passed for such queries.

The implementation of this interface should cache the starting conditions and ending conditions
of animations as needed.

__Note__: `Animation` does not track the lifecycle of an animation. It merely reacts to play time
change and returns the new value/velocity as a result. It can be used as a building block for
more lifecycle aware animations. In contrast, `Animatable` and `Transition` are stateful and
manage their own lifecycles.


## Functions

```kotlin
public fun getValueFromNanos(playTimeNanos: Long): T
```


Returns the value of the animation at the given play time.

#### Parameters

| | |
| --- | --- |
| playTimeNanos | the play time that is used to determine the value of the animation. |



```kotlin
public fun getVelocityVectorFromNanos(playTimeNanos: Long): V
```


Returns the velocity (in `AnimationVector` form) of the animation at the given play time.

#### Parameters

| | |
| --- | --- |
| playTimeNanos | the play time that is used to calculate the velocity of the animation. |



```kotlin
public fun isFinishedFromNanos(playTimeNanos: Long): Boolean
```


Returns whether the animation is finished at the given play time.

#### Parameters

| | |
| --- | --- |
| playTimeNanos | the play time used to determine whether the animation is finished. |




