<!--
{
  "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/ScrollTargetBehavior/updateTarget(_:context:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI20ScrollTargetBehaviorP06updateD0_7contextyAA0cD0Vz_AA0cdE7ContextVtF"
  },
  "title" : "updateTarget(_:context:)"
}
-->

# updateTarget(_:context:)

Updates the proposed target that a scrollable view should scroll to.

```
func updateTarget(_ target: inout ScrollTarget, context: Self.TargetContext)
```

## Discussion

The system calls this method in two main cases:

- When a scroll gesture ends, it calculates where it would naturally
  scroll to using its deceleration rate. The system
  provides this calculated value as the target of this method.
- When a scrollable view’s size changes, it calculates where it should
  be scrolled given the new size and provides this calculates value
  as the target of this method.

You can implement this method to override the calculated target
which will have the scrollable view scroll to a different position
than it would otherwise.

---

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)