tangled
alpha
login
or
join now
jonmsterling.com
/
AquaKit
4
fork
atom
A collection of user interface components and drawing routines for building tasteful apps using AppKit.
appkit
swift
aqua
ui
mac
4
fork
atom
overview
issues
1
pulls
pipelines
Drawer resizing: work around an edge case
jonmsterling.com
3 weeks ago
9ec6ed24
d25e8aa5
+10
-3
1 changed file
expand all
collapse all
unified
split
Sources
AquaKit
Drawers
AquaDrawer.swift
+10
-3
Sources/AquaKit/Drawers/AquaDrawer.swift
···
271
271
}
272
272
}
273
273
274
274
+
private func finalizeClose() {
275
275
+
self.window?.orderOut(nil)
276
276
+
self.state = .closedState
277
277
+
NotificationCenter.default.post(name: Self.didCloseNotification, object: self)
278
278
+
}
279
279
+
274
280
public override func close() {
275
281
guard
276
282
case .openState(let edge) = state,
···
283
289
NotificationCenter.default.post(name: Self.willCloseNotification, object: self)
284
290
state = .closingState
285
291
292
292
+
// Edge case: when the window has zero size, its origin may turn to zero for reasons unknown. To avoid the resulting animation glitch, we just don't animate at all in this case.
293
293
+
guard window.frame != .zero else { return finalizeClose() }
294
294
+
286
295
NSAnimationContext.runAnimationGroup { context in
287
296
context.duration = Self.drawerTransitionDuration
288
297
window.animator().setFrame(frame, display: true)
289
298
} completionHandler: { [weak self] in
290
299
if let self {
291
300
Task { @MainActor in
292
292
-
self.window?.orderOut(nil)
293
293
-
self.state = .closedState
294
294
-
NotificationCenter.default.post(name: Self.didCloseNotification, object: self)
301
301
+
self.finalizeClose()
295
302
}
296
303
}
297
304
}