I have a pretty simple requirement for tabbed navigation (a couple of tabs at the bottom and a couple of pages/views):
- If I click/tap a tab, there should be a transition to the next view.
- Views/Pages should not get removed from the DOM (because they should keep their scroll-positions, etc…)
- tab-links should be set to
active
I tried some variations, but somehow I either loose animation or pages are removed from DOM:
Below are some variations I tried without success. The variations are wrapped into a views
div, like so:
<f7-views tabs id="main-view" url="/" main>
<---variations here--->
</f7-views>
Variation 1:
Here, views are shown correctly, tab-links are automatically set to ‘active’ and animation is correct, but views get re-created every time:
<f7-toolbar tabbar labels>
<f7-link tab-link tab-link-active route-tab-id="#view-home" href="/" :animate="true" text="Home"></f7-link>
<!--...-->
<f7-link tab-link route-tab-id="#view-settings" href="/settings/" :animate="true" text="Settings"></f7-link>
</f7-toolbar>
<f7-view id="view-home" name="home" main tab tab-active url="/"></f7-view>
Variation 2:
Basically, same as V1, but using stackPages
: Now pages are stacked, but re-created every time they get shown (so I have plenty of duplicate pages
in the DOM (and scroll-positions are not retained):
<f7-toolbar tabbar labels>
<f7-link tab-link tab-link-active route-tab-id="home" href="/" animate text="Home"></f7-link>
<!--...-->
<f7-link tab-link tab-link-active route-tab-id="view-settings" href="/settings/" animate text="Settings"></f7-link>
</f7-toolbar>
<f7-view id="view-home" stackPages="true" name="home" main tab tab-active url="/" data-animate="true"></f7-view>
Variation 3:
This way, everything works fine and elements are kept in DOM, but there’s no page-transition:
<f7-toolbar tabbar labels>
<f7-link tab-link tab-link-active href="#view-home" :animate="true" text="Home"></f7-link>
<!--...-->
<f7-link tab-link tab-link-active href="#view-settings" :animate="true" text="Settings"></f7-link>
</f7-toolbar>
<f7-view id="view-home" name="home" main tab tab-active url="/" :animate="true" </f7-view>
<!--...-->
<f7-view id="view-settings" name="settings" tab url="/settings/" :animate="true"></f7-view>
I am pretty sure I’m doing something wrong here…
Sorry for a lengthy question, but this is hard to put into a jsfiddle…
Any hint?