问题
I am using default ion-tab-bar with bottom placement as shown in the LinkedIn app. I want to hide the tab-bar while scrolling and show it again when scrolling stops. This feature can be seen in the LinkedIn app.
Here is 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>
回答1:
Add this to the 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';
});
}
This will do the trick...
来源:https://stackoverflow.com/questions/54307676/ionic-4-hide-ion-tab-bar-while-scrolling-just-like-linkedin-app