---
title: "velocity(value:time:context:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/customanimation/velocity(value:time:context:)"
---

# velocity(value:time:context:)

Calculates the velocity of the animation at a specified time.

## Declaration

```swift
nonisolated func velocity<V>(value: V, time: TimeInterval, context: AnimationContext<V>) -> V? where V : VectorArithmetic
```

## Parameters

- `value`: The vector to animate towards.
- `time`: The amount of time since the start of the animation.
- `context`: An instance of doc://com.apple.SwiftUI/documentation/SwiftUI/AnimationContext that provides access to state and the animation environment.

## Return Value

Return Value The current velocity of the animation, or nil if the animation has finished.

## Discussion

Discussion Implement this method to provide the velocity of the animation at a given time. Should subsequent animations merge with the animation, the system preserves continuity of the velocity between animations. The default implementation of this method returns nil. note: State and environment data is available to this method via the context parameter, but context is read-only. This behavior is different than with animate(value:time:context:) and shouldMerge(previous:value:time:context:) where context is an inout parameter, letting you change the context including state data of the animation. For more information about managing state data in a custom animation, see AnimationContext.
