【问题标题】:Ionic 4 : Hide ion-tab-bar while scrolling, just like LinkedIn appIonic 4:滚动时隐藏 ion-tab-bar,就像 LinkedIn 应用程序一样
【发布时间】:2019-01-22 11:49:34
【问题描述】:

我正在使用默认的 ion-tab-bar 底部放置,如 LinkedIn 应用程序所示。 我想在滚动时隐藏标签栏,并在滚动停止时再次显示它。可以在 LinkedIn 应用中看到此功能。

这里是 tabs.page.html

<ion-tabs >

  <ion-tab-bar slot="bottom" >
    <ion-tab-button tab="tab1">
      <ion-icon name="desktop"></ion-icon>
      <ion-label>Tab Three</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="tab2">
      <ion-icon name="person"></ion-icon>
      <ion-label>Tab Two</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="tab3">
      <ion-icon name="send"></ion-icon>
      <ion-label>Tab Three</ion-label>
    </ion-tab-button>
  </ion-tab-bar>

</ion-tabs>

【问题讨论】:

    标签: angular ionic-framework ionic4


    【解决方案1】:

    将此添加到tab.page.ts

      ngOnInit() {
        let content = document.querySelector('ion-content');
        content.scrollEvents = true;
        content.addEventListener('ionScrollStart', () => {
              document.querySelector('ion-tab-bar').style.display = 'none';
        });
        content.addEventListener('ionScrollEnd', () => {
              document.querySelector('ion-tab-bar').style.display = 'flex';
        });
       }
    

    这样就可以了...

    【讨论】:

    • 是的,它可以工作,但有一个错误,当滚动在屏幕中间时,屏幕会开始自动上下滚动,所以看起来会闪烁。
    • 可能,这是主要方法,我建议你玩一下前:添加fadein fadeout 也许一些settimeout 用于小延迟等基于您的应用程序。很难假设那里真正发生了什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-28
    • 2020-10-28
    • 1970-01-01
    • 1970-01-01
    • 2019-07-10
    • 2019-06-13
    相关资源
    最近更新 更多