Is there any good example of a scrollable tab bar using ionic2. I have tried to use ion-scroll but it does not work for me. A good example would be appreciated as it is a fairly normal scenario. scrolling should be a property of menu, list…and not something separate.
I had something fairly usable using tabbar listening to change events on ion-slides. That was fairly simple but felt quite slow. I ended up tweaking the ionic library to improve the feeling of it and the final result was quite good
By memory, ionic was waiting until the transition from the slider was completely finish to trigger the change event (which was feeling like a weird latency on actual device). However I read a bit on swiperjs (which is the libraries they use) and was able to fix it by triggering the change update when the change start. It was feeling way better.
In other word I had the hack in node_modules/ionic-framework/components/slides/slide.js, just can’t find the code back …
just a slider, a tabbar and listening to the slideChangeStart to update the tab correctly and it works!!
Another bit of code to handle the tab click and voila
That was just a poc for a prototype and I didn’t move forward with this design, but here it was:
<ion-toolbar>
<ion-segment [(ngModel)]="currState">
<ion-segment-button value="0">
A
</ion-segment-button>
<ion-segment-button value="1">
B
</ion-segment-button>
<ion-segment-button value="2">
C
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<ion-content>
<ion-slides index={{currState}} (change)="onTabUpdate($event)">
<ion-slide>
<scroll-content>
anything you want here
</scroll-content>
</ion-slide>
</ion-slides>
</ion-content>
and something like that in the controller:
onTabUpdate(event){
let newIndexAfterUpdate = event.activeIndex;
this.currState = String(newIndexAfterUpdate);
}
Quite simple, no fancy thing here
As said in the previous post, you can now plug directly in the event that was add a few days ago so that you won’t need to hack the inside of ionic anymore.