@@ -190,26 +190,15 @@ export class TabBar implements ComponentInterface {
190190 private async initScrollListener ( contentEl : HTMLElement ) {
191191 const scrollEl = ( this . scrollEl = await getScrollElement ( contentEl ) ) ;
192192
193- const scrollThreshold = 10 ;
194-
195193 this . contentScrollCallback = ( ) => {
196194 readTask ( ( ) => {
197195 const scrollTop = scrollEl . scrollTop ;
198- const isScrollingDown = scrollTop > this . lastScrollTop ;
199-
200- if ( isScrollingDown !== this . lastScrollTop > this . scrollDirectionChangeTop ) {
201- this . scrollDirectionChangeTop = this . lastScrollTop ;
202- }
203-
204- const delta = Math . abs ( scrollTop - this . scrollDirectionChangeTop ) ;
196+ const shouldHide = this . checkScrollStatus ( scrollTop ) ;
205197
206- if ( delta >= scrollThreshold ) {
207- const shouldHide = isScrollingDown && scrollTop > 0 ;
208- if ( shouldHide !== this . scrollHidden ) {
209- writeTask ( ( ) => {
210- this . scrollHidden = shouldHide ;
211- } ) ;
212- }
198+ if ( shouldHide !== this . scrollHidden ) {
199+ writeTask ( ( ) => {
200+ this . scrollHidden = shouldHide ;
201+ } ) ;
213202 }
214203
215204 this . lastScrollTop = scrollTop ;
@@ -226,6 +215,33 @@ export class TabBar implements ComponentInterface {
226215 }
227216 }
228217
218+ private checkScrollStatus ( scrollTop : number ) : boolean {
219+ // Always visible within the first 80px of scroll
220+ const visibleZone = 80 ;
221+ // Hides after 60px of continuous downward scrolling only, when scrolling up threashold should be 0px
222+ const scrollThresholdHide = 60 ;
223+
224+ if ( scrollTop <= visibleZone ) {
225+ return false ;
226+ }
227+
228+ const isScrollingDown = scrollTop > this . lastScrollTop ;
229+ const wasScrollingDown = this . lastScrollTop > this . scrollDirectionChangeTop ;
230+
231+ if ( isScrollingDown !== wasScrollingDown ) {
232+ this . scrollDirectionChangeTop = this . lastScrollTop ;
233+ }
234+
235+ const delta = Math . abs ( scrollTop - this . scrollDirectionChangeTop ) ;
236+ const threshold = isScrollingDown ? scrollThresholdHide : 0 ;
237+
238+ if ( delta < threshold ) {
239+ return this . scrollHidden ;
240+ }
241+
242+ return isScrollingDown ;
243+ }
244+
229245 private getShape ( ) : string | undefined {
230246 const theme = getIonTheme ( this ) ;
231247 const { shape } = this ;
0 commit comments