<!--
{
  "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/Transaction/tracksVelocity",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11TransactionV14tracksVelocitySbvp"
  },
  "title" : "tracksVelocity"
}
-->

# tracksVelocity

Whether this transaction will track the velocity of any animatable
properties that change.

```
var tracksVelocity: Bool { get set }
```

## Discussion

This property can be enabled in an interactive context to track velocity
during a user interaction so that when the interaction ends, an
animation can use the accumulated velocities to create animations that
preserve them. This tracking is mutually exclusive with an animation
being used during a view change, since if there is an animation, it is
responsible for managing its own velocity.

Gesture onChanged and updating callbacks automatically set this property
to true.

This example shows an interaction which applies changes, tracking
velocity until the final change, which applies an animation (which will
start with the velocity that was tracked during the previous changes).
These changes could come from a server or from an interactive control
like a slider.

```
func receiveChange(change: ChangeInfo) {
    var transaction = Transaction()
    if change.isFinal {
        transaction.animation = .spring
    } else {
        transaction.tracksVelocity = true
    }
    withTransaction(transaction) {
        state.applyChange(change)
    }
}
```

---

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)