<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSClipView/constrainScroll(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSClipView(im)constrainScrollPoint:"
  },
  "title" : "constrainScroll(_:)"
}
-->

# constrainScroll(_:)

Returns a scroll point adjusted from the proposed new origin, if necessary, to guarantee the view will lie within its document view.

```
func constrainScroll(_ newOrigin: NSPoint) -> NSPoint
```

## Parameters

`newOrigin`

Origin proposed.

## Return Value

A point which will guarantee the view will lie within its document view.

## Discussion

For example, if the x-coordinate of `newOrigin` lies to the left of the document view’s origin, then the x-coordinate returned is set to that of the x-coordinate of the document view’s origin.

---

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)