---
title: "constrainScroll(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsclipview/constrainscroll(_:)"
---

# constrainScroll(_:)

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

## Declaration

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

## Parameters

- `newOrigin`: Origin proposed.

## Return Value

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

## Discussion

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.

## See Also

### Scrolling

- [scroll(to:)](appkit/nsclipview/scroll(to:).md)
- [autoscroll(with:)](appkit/nsclipview/autoscroll(with:).md)
- [constrainBoundsRect(_:)](appkit/nsclipview/constrainboundsrect(_:).md)
