@@ -59,20 +59,24 @@ struct HorizontalSplitView<Leading: View, Trailing: View>: NSViewRepresentable {
5959
6060 if isTrailingCollapsed != wasCollapsed {
6161 context. coordinator. lastCollapsedState = isTrailingCollapsed
62- if isTrailingCollapsed {
63- if splitView. subviews. count >= 2 {
64- context. coordinator. savedDividerPosition = splitView. subviews [ 1 ] . frame. width
62+ NSAnimationContext . runAnimationGroup { ctx in
63+ ctx. duration = 0.2
64+ ctx. timingFunction = CAMediaTimingFunction ( name: . easeInEaseOut)
65+ ctx. allowsImplicitAnimation = true
66+
67+ if isTrailingCollapsed {
68+ if splitView. subviews. count >= 2 {
69+ context. coordinator. savedDividerPosition = splitView. subviews [ 1 ] . frame. width
70+ }
71+ splitView. setPosition ( splitView. bounds. width, ofDividerAt: 0 )
72+ trailingView. isHidden = true
73+ } else {
74+ trailingView. isHidden = false
75+ splitView. adjustSubviews ( )
76+ if let saved = context. coordinator. savedDividerPosition {
77+ splitView. setPosition ( splitView. bounds. width - saved, ofDividerAt: 0 )
78+ }
6579 }
66- splitView. setPosition ( splitView. bounds. width, ofDividerAt: 0 )
67- trailingView. isHidden = true
68- splitView. display ( )
69- } else {
70- trailingView. isHidden = false
71- splitView. adjustSubviews ( )
72- if let saved = context. coordinator. savedDividerPosition {
73- splitView. setPosition ( splitView. bounds. width - saved, ofDividerAt: 0 )
74- }
75- splitView. display ( )
7680 }
7781 }
7882 }
0 commit comments