@@ -33,7 +33,7 @@ export class Maximizer extends Service {
3333
3434 const self = this
3535 this . register ( around ( app . workspace , {
36- setActiveLeaf ( old ) { return function setActiveLeaf ( leaf , pushHistory , focus ) {
36+ setActiveLeaf ( old ) { return function setActiveLeaf ( leaf , ... args : any [ ] ) {
3737 // We have to do this here so that MarkdownView can be focused in the new pane
3838 const parent = self . parentForLeaf ( leaf ) , oldParent = self . parentForLeaf ( app . workspace . activeLeaf ) ;
3939 if (
@@ -46,17 +46,9 @@ export class Maximizer extends Service {
4646 app . commands . executeCommandById ( "obsidian-hover-editor:restore-active-popover" ) ;
4747 }
4848 if ( isMain ( leaf ) && parent ) self . refresh ( parent , parent . hasClass ( "should-maximize" ) ? leaf . containerEl : null ) ;
49- return old . call ( this , leaf , pushHistory , focus ) ;
49+ return old . call ( this , leaf , ... args ) ;
5050 } }
5151 } ) ) ;
52- this . register ( around ( WorkspaceTabs . prototype , {
53- onContainerScroll ( old ) {
54- return function ( ) {
55- // Don't hide tabs while we're switching modes
56- if ( ! self . changing && this . containerEl . isShown ( ) ) return old . call ( this )
57- }
58- }
59- } ) )
6052
6153 // Replace the right sidebar toggle that gets hidden during maximize
6254 app . workspace . onLayoutReady ( ( ) => {
@@ -106,18 +98,22 @@ export class Maximizer extends Service {
10698 return ;
10799 }
108100 }
109- if ( parent ) this . refresh ( parent , toggleClass ( parent , "should-maximize" ) ? leaf . containerEl : null ) ;
101+ let hadMax = ! toggleClass ( parent , "should-maximize" ) ;
102+ if ( parent ) this . refresh ( parent , hadMax ? null : leaf . containerEl , hadMax ) ;
110103 }
111104
112105 lastMaximized ( parent : Element ) {
113106 return parent . find ( ".workspace-leaf.is-maximized" ) || app . workspace . getMostRecentLeaf ( ) . containerEl ;
114107 }
115108
116109 fixSlidingPanes = debounce ( ( ) => {
117- const parent = app . workspace . activeLeaf . parentSplit ;
118- if ( requireApiVersion ( "0.16.2" ) && parent instanceof WorkspaceTabs && parent . isStacked ) {
119- parent . containerEl . win . requestAnimationFrame ( ( ) => {
110+ activeWindow . requestAnimationFrame ( ( ) => {
111+ const { activeLeaf} = app . workspace ;
112+ if ( ! activeLeaf ) return ;
113+ const parent = activeLeaf . parentSplit ;
114+ if ( requireApiVersion ( "0.16.2" ) && parent instanceof WorkspaceTabs && parent . isStacked ) {
120115 const remove = around ( parent . tabsContainerEl , {
116+ // Kill .behavior flag so that the *whole* tab scrolls to position
121117 scrollTo ( old ) { return function ( optionsOrX , y ?: number ) {
122118 if ( typeof optionsOrX === "object" ) {
123119 delete optionsOrX . behavior ;
@@ -127,20 +123,20 @@ export class Maximizer extends Service {
127123 } }
128124 } ) ;
129125 try { parent . scrollIntoView ( parent . currentTab ) ; } finally { remove ( ) ; this . changing = false ; }
130- } ) ;
131- } else {
132- app . workspace . requestActiveLeafEvents ( ) ;
133- this . changing = false ;
134- }
126+ } else {
127+ this . changing = false ;
128+ }
129+ activeLeaf . containerEl . scrollIntoView ( ) ;
130+ } ) ;
135131 } , 1 , true ) ;
136132
137133 refresh (
138134 parent : Element ,
139135 leafEl : Element =
140- parent . hasClass ( "should-maximize" ) ? this . lastMaximized ( parent ) : null
136+ parent . hasClass ( "should-maximize" ) ? this . lastMaximized ( parent ) : null ,
137+ hadMax = parent . hasClass ( "has-maximized" )
141138 ) {
142139 this . changing = true ;
143- const hadMax = parent . hasClass ( "has-maximized" ) ;
144140 parent . findAllSelf ( ".workspace-split, .workspace-tabs" ) . forEach ( split => {
145141 if ( split === parent || this . parentFor ( split ) === parent )
146142 toggleClass ( split , "has-maximized" , leafEl ? split . contains ( leafEl ) : false ) ;
0 commit comments