离子4:滚动时隐藏离子标签条,就像LinkedIn应用程序一样



我使用的是默认的离子标签条,底部放置如LinkedIn应用程序所示。我想在滚动时隐藏选项卡栏,并在滚动停止时再次显示它。此功能可以在LinkedIn应用程序中看到。

这是标签页面.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>

将其添加到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';
    });
   }

这将解决问题...

最新更新