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

Open
sindresorhus opened this issue Aug 5, 2019 · 1 comment

Comments

@sindresorhus
Copy link
Owner

commented Aug 5, 2019

Issuehunt badges

Currently, we do this:

Gifski/Gifski/util.swift

Lines 2436 to 2455 in 56511ac

func push(viewController: NSViewController, completion: (() -> Void)? = nil) {
guard let window = view.window else {
return
}
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
window.makeFirstResponder(viewController)
completion?()
})
}

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.

https://developer.apple.com/documentation/appkit/nsviewcontroller/1434431-present
https://stackoverflow.com/questions/28454291/transitioning-between-view-controller-os-x/28493373#28493373


IssueHunt Summary

Backers (Total: $60.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips


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

@issuehunt-app

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
Projects
None yet
1 participant
You can’t perform that action at this time.