<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/CustomAnimation/velocity(value:time:context:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15CustomAnimationP8velocity5value4time7contextqd__Sgqd___SdAA0D7ContextVyqd__GtAA16VectorArithmeticRd__lF"
  },
  "title" : "velocity(value:time:context:)"
}
-->

# velocity(value:time:context:)

Calculates the velocity of the animation at a specified time.

```
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 [`AnimationContext`](/documentation/SwiftUI/AnimationContext) that provides access
to state and the animation environment.

## Return Value

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

## 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 ``doc://com.apple.SwiftUI/documentation/SwiftUI/CustomAnimation/animate(value:time:context:)`` and
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/CustomAnimation/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 ``doc://com.apple.SwiftUI/documentation/SwiftUI/AnimationContext``.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)