Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use `NSViewController.present()` with custom animator #108

sindresorhus opened this issue Aug 5, 2019 · 1 comment


Copy link

commented Aug 5, 2019

Issuehunt badges

Currently, we do this:


Lines 2436 to 2455 in 56511ac

func push(viewController: NSViewController, completion: (() -> Void)? = nil) {
guard let window = view.window else {
let newOrigin = CGPoint(x: window.frame.midX - viewController.view.frame.width / 2.0, y: window.frame.midY - viewController.view.frame.height / 2.0)
let newWindowFrame = CGRect(origin: newOrigin, size: viewController.view.frame.size)
viewController.view.alphaValue = 0.0
NSAnimationContext.runAnimationGroup({ _ in
window.contentViewController?.view.animator().alphaValue = 0.0
window.contentViewController = nil
window.animator().setFrame(newWindowFrame, display: true)
}, completionHandler: {
window.contentViewController = viewController
viewController.view.animator().alphaValue = 1.0

The benefit of using present is that it's possible to dismiss the view controller to go back to the previous one. For example, when the user cancels the editing, we could just dismiss that view controller.

IssueHunt Summary

Backers (Total: $60.00)

Become a backer now!

Or submit a pull request to get the deposits!


IssueHunt has been backed by the following sponsors. Become a sponsor


This comment has been minimized.

Copy link

commented Aug 6, 2019

@issuehunt has funded $60.00 to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.