MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / Tabs

Class Tabs

core/src/components/tabs/tabs.tsx:18–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 shadow: true,
17})
18export class Tabs implements NavOutlet {
19 private transitioning = false;
20 private leavingTab?: HTMLIonTabElement;
21
22 @Element() el!: HTMLIonTabsElement;
23
24 @State() selectedTab?: HTMLIonTabElement;
25
26 /** @internal */
27 @Prop({ mutable: true }) useRouter = false;
28
29 /**
30 * Emitted when the navigation will load a component.
31 * @internal
32 */
33 @Event() ionNavWillLoad!: EventEmitter<void>;
34
35 /**
36 * Emitted when the navigation is about to transition to a new component.
37 */
38 @Event({ bubbles: false }) ionTabsWillChange!: EventEmitter<{ tab: string }>;
39
40 /**
41 * Emitted when the navigation has finished transitioning to a new component.
42 */
43 @Event({ bubbles: false }) ionTabsDidChange!: EventEmitter<{ tab: string }>;
44
45 async componentWillLoad() {
46 if (!this.useRouter) {
47 /**
48 * JavaScript and StencilJS use `ion-router`, while
49 * the other frameworks use `ion-router-outlet`.
50 *
51 * If either component is present then tabs will not use
52 * a basic tab-based navigation. It will use the history
53 * stack or URL updates associated with the router.
54 */
55 this.useRouter =
56 (!!this.el.querySelector('ion-router-outlet') || !!document.querySelector('ion-router')) &&
57 !this.el.closest('[no-router]');
58 }
59 if (!this.useRouter) {
60 const tabs = this.tabs;
61 if (tabs.length > 0) {
62 await this.select(tabs[0]);
63 }
64 }
65 this.ionNavWillLoad.emit();
66 }
67
68 componentDidLoad() {
69 this.updateTabBar();
70 }
71
72 componentDidUpdate() {
73 this.updateTabBar();
74 }
75

Callers

nothing calls this directly

Calls 2

selectMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected