@@ -57,14 +57,10 @@ export class Header implements ComponentInterface {
57
57
// Determine if the header can collapse
58
58
const hasCollapse = this . collapse === 'condense' ;
59
59
const canCollapse = ( hasCollapse && getIonMode ( this ) === 'ios' ) ? hasCollapse : false ;
60
-
61
60
if ( ! canCollapse && this . collapsibleHeaderInitialized ) {
62
61
this . destroyCollapsibleHeader ( ) ;
63
62
} else if ( canCollapse && ! this . collapsibleHeaderInitialized ) {
64
- const tabs = this . el . closest ( 'ion-tabs' ) ;
65
- const page = this . el . closest ( 'ion-app,ion-page,.ion-page,page-inner' ) ;
66
-
67
- const pageEl = ( tabs ) ? tabs : ( page ) ? page : null ;
63
+ const pageEl = this . el . closest ( 'ion-app,ion-page,.ion-page,page-inner' ) ;
68
64
const contentEl = ( pageEl ) ? pageEl . querySelector ( 'ion-content' ) : null ;
69
65
70
66
await this . setupCollapsibleHeader ( contentEl , pageEl ) ;
@@ -101,21 +97,17 @@ export class Header implements ComponentInterface {
101
97
102
98
setHeaderActive ( mainHeaderIndex , false ) ;
103
99
104
- // TODO: Find a better way to do this
105
- let remainingHeight = 0 ;
106
- for ( let i = 1 ; i <= scrollHeaderIndex . toolbars . length - 1 ; i ++ ) {
107
- remainingHeight += scrollHeaderIndex . toolbars [ i ] . el . clientHeight ;
108
- }
109
-
110
- /**
111
- * Handle interaction between toolbar collapse and
112
- * showing/hiding content in the primary ion-header
113
- */
114
- const toolbarIntersection = ( ev : any ) => { handleToolbarIntersection ( ev , mainHeaderIndex , scrollHeaderIndex ) ; } ;
115
-
116
100
readTask ( ( ) => {
117
101
const mainHeaderHeight = mainHeaderIndex . el . clientHeight ;
118
- this . intersectionObserver = new IntersectionObserver ( toolbarIntersection , { threshold : 0.25 , rootMargin : `-${ mainHeaderHeight } px 0px 0px 0px` } ) ;
102
+
103
+ /**
104
+ * Handle interaction between toolbar collapse and
105
+ * showing/hiding content in the primary ion-header
106
+ * as well as progressively showing/hiding the main header
107
+ * border as the top-most toolbar collapses or expands.
108
+ */
109
+ const toolbarIntersection = ( ev : any ) => { handleToolbarIntersection ( ev , mainHeaderIndex , scrollHeaderIndex ) ; } ;
110
+ this . intersectionObserver = new IntersectionObserver ( toolbarIntersection , { threshold : [ 0.25 , 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1 ] , rootMargin : `-${ mainHeaderHeight } px 0px 0px 0px` } ) ;
119
111
this . intersectionObserver . observe ( scrollHeaderIndex . toolbars [ 0 ] . el ) ;
120
112
} ) ;
121
113
@@ -124,7 +116,7 @@ export class Header implements ComponentInterface {
124
116
* showing/hiding border on last toolbar
125
117
* in primary header
126
118
*/
127
- this . contentScrollCallback = ( ) => { handleContentScroll ( this . scrollEl ! , mainHeaderIndex , scrollHeaderIndex , remainingHeight ) ; } ;
119
+ this . contentScrollCallback = ( ) => { handleContentScroll ( this . scrollEl ! , scrollHeaderIndex ) ; } ;
128
120
this . scrollEl . addEventListener ( 'scroll' , this . contentScrollCallback ) ;
129
121
} ) ;
130
122
0 commit comments