@materializecss/materialize 2.0.1-alpha → 2.0.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Gruntfile.js +5 -2
- package/dist/css/materialize.css +1510 -288
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2782 -2688
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/dist/src/autocomplete.d.ts +143 -0
- package/dist/src/autocomplete.d.ts.map +1 -0
- package/dist/src/bounding.d.ts +7 -0
- package/dist/src/bounding.d.ts.map +1 -0
- package/dist/src/buttons.d.ts +65 -0
- package/dist/src/buttons.d.ts.map +1 -0
- package/dist/src/cards.d.ts +4 -0
- package/dist/src/cards.d.ts.map +1 -0
- package/dist/src/carousel.d.ts +131 -0
- package/dist/src/carousel.d.ts.map +1 -0
- package/dist/src/characterCounter.d.ts +37 -0
- package/dist/src/characterCounter.d.ts.map +1 -0
- package/dist/src/chips.d.ts +131 -0
- package/dist/src/chips.d.ts.map +1 -0
- package/dist/src/collapsible.d.ts +74 -0
- package/dist/src/collapsible.d.ts.map +1 -0
- package/dist/src/component.d.ts +74 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/datepicker.d.ts +248 -0
- package/dist/src/datepicker.d.ts.map +1 -0
- package/dist/src/dropdown.d.ts +148 -0
- package/dist/src/dropdown.d.ts.map +1 -0
- package/dist/src/edges.d.ts +7 -0
- package/dist/src/edges.d.ts.map +1 -0
- package/dist/src/forms.d.ts +12 -0
- package/dist/src/forms.d.ts.map +1 -0
- package/dist/src/global.d.ts +60 -0
- package/dist/src/global.d.ts.map +1 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/materialbox.d.ts +92 -0
- package/dist/src/materialbox.d.ts.map +1 -0
- package/dist/src/modal.d.ts +119 -0
- package/dist/src/modal.d.ts.map +1 -0
- package/dist/src/parallax.d.ts +40 -0
- package/dist/src/parallax.d.ts.map +1 -0
- package/dist/src/pushpin.d.ts +52 -0
- package/dist/src/pushpin.d.ts.map +1 -0
- package/dist/src/range.d.ts +41 -0
- package/dist/src/range.d.ts.map +1 -0
- package/dist/src/scrollspy.d.ts +62 -0
- package/dist/src/scrollspy.d.ts.map +1 -0
- package/dist/src/select.d.ts +77 -0
- package/dist/src/select.d.ts.map +1 -0
- package/dist/src/sidenav.d.ts +122 -0
- package/dist/src/sidenav.d.ts.map +1 -0
- package/dist/src/slider.d.ts +103 -0
- package/dist/src/slider.d.ts.map +1 -0
- package/dist/src/tabs.d.ts +80 -0
- package/dist/src/tabs.d.ts.map +1 -0
- package/dist/src/tapTarget.d.ts +59 -0
- package/dist/src/tapTarget.d.ts.map +1 -0
- package/dist/src/timepicker.d.ts +208 -0
- package/dist/src/timepicker.d.ts.map +1 -0
- package/dist/src/toasts.d.ts +90 -0
- package/dist/src/toasts.d.ts.map +1 -0
- package/dist/src/tooltip.d.ts +112 -0
- package/dist/src/tooltip.d.ts.map +1 -0
- package/dist/src/utils.d.ts +97 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/waves.d.ts +16 -0
- package/dist/src/waves.d.ts.map +1 -0
- package/package.json +4 -1
- package/sass/components/_cards.scss +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +53 -2
- package/sass/components/_grid.scss +28 -47
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +30 -27
- package/sass/components/_pulse.scss +1 -0
- package/sass/components/_sidenav.scss +63 -45
- package/sass/components/_theme_variables.scss +29 -49
- package/sass/components/_typography.scss +2 -2
- package/sass/components/_variables.scss +2 -0
- package/sass/components/colors.module.scss +180 -0
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/components/theme.dark.module.scss +32 -0
- package/sass/components/theme.light.module.scss +32 -0
- package/sass/components/tokens.module.scss +272 -0
- package/sass/components/typography.module.scss +150 -0
- package/sass/materialize.scss +6 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +573 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +36 -24
- package/src/global.ts +57 -328
- package/src/index.ts +26 -0
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- package/src/waves.ts +10 -10
package/src/tabs.ts
CHANGED
|
@@ -1,107 +1,153 @@
|
|
|
1
|
-
import { Component } from "./component";
|
|
2
|
-
import { Carousel } from "./carousel";
|
|
3
1
|
import anim from "animejs";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import { Carousel } from "./carousel";
|
|
4
|
+
import { Component, BaseOptions, InitElements, MElement } from "./component";
|
|
5
|
+
|
|
6
|
+
export interface TabsOptions extends BaseOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Transition duration in milliseconds.
|
|
9
|
+
* @default 300
|
|
10
|
+
*/
|
|
11
|
+
duration: number;
|
|
12
|
+
/**
|
|
13
|
+
* Callback for when a new tab content is shown.
|
|
14
|
+
* @default null
|
|
15
|
+
*/
|
|
16
|
+
onShow: (newContent: Element) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Set to true to enable swipeable tabs.
|
|
19
|
+
* This also uses the responsiveThreshold option.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
swipeable: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum width of the screen, in pixels,
|
|
25
|
+
* where the swipeable functionality initializes.
|
|
26
|
+
* @default infinity
|
|
27
|
+
*/
|
|
28
|
+
responsiveThreshold: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let _defaults: TabsOptions = {
|
|
6
32
|
duration: 300,
|
|
7
33
|
onShow: null,
|
|
8
34
|
swipeable: false,
|
|
9
|
-
responsiveThreshold: Infinity
|
|
35
|
+
responsiveThreshold: Infinity // breakpoint for swipeable
|
|
10
36
|
};
|
|
11
37
|
|
|
12
|
-
export class Tabs extends Component {
|
|
13
|
-
|
|
14
|
-
_tabLinks: any;
|
|
38
|
+
export class Tabs extends Component<TabsOptions> {
|
|
39
|
+
_tabLinks: NodeListOf<HTMLAnchorElement>;
|
|
15
40
|
_index: number;
|
|
16
41
|
_indicator: any;
|
|
17
|
-
_handleWindowResizeBound: (this: Window, ev: UIEvent) => any;
|
|
18
|
-
_handleTabClickBound: (this: Window, ev: UIEvent) => any;
|
|
19
42
|
_tabWidth: number;
|
|
20
43
|
_tabsWidth: number;
|
|
21
44
|
_tabsCarousel: any;
|
|
22
45
|
_activeTabLink: any;
|
|
23
46
|
_content: any;
|
|
24
47
|
|
|
25
|
-
constructor(el, options:
|
|
26
|
-
super(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this._setupEventHandlers();
|
|
48
|
+
constructor(el: HTMLElement, options: Partial<TabsOptions>) {
|
|
49
|
+
super(el, options, Tabs);
|
|
50
|
+
(this.el as any).M_Tabs = this;
|
|
51
|
+
|
|
52
|
+
this.options = {
|
|
53
|
+
...Tabs.defaults,
|
|
54
|
+
...options
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this._tabLinks = this.el.querySelectorAll('li.tab > a');
|
|
58
|
+
this._index = 0;
|
|
59
|
+
this._setupActiveTabLink();
|
|
60
|
+
if (this.options.swipeable) {
|
|
61
|
+
this._setupSwipeableTabs();
|
|
62
|
+
} else {
|
|
63
|
+
this._setupNormalTabs();
|
|
42
64
|
}
|
|
65
|
+
// Setup tabs indicator after content to ensure accurate widths
|
|
66
|
+
this._setTabsAndTabWidth();
|
|
67
|
+
this._createIndicator();
|
|
68
|
+
this._setupEventHandlers();
|
|
69
|
+
}
|
|
43
70
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
static get defaults(): TabsOptions {
|
|
72
|
+
return _defaults;
|
|
73
|
+
}
|
|
47
74
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Initializes instance of Tabs.
|
|
77
|
+
* @param el HTML element.
|
|
78
|
+
* @param options Component options.
|
|
79
|
+
*/
|
|
80
|
+
static init(el: HTMLElement, options?: Partial<TabsOptions>): Tabs;
|
|
81
|
+
/**
|
|
82
|
+
* Initializes instances of Tabs.
|
|
83
|
+
* @param els HTML elements.
|
|
84
|
+
* @param options Component options.
|
|
85
|
+
*/
|
|
86
|
+
static init(els: InitElements<MElement>, options?: Partial<TabsOptions>): Tabs[];
|
|
87
|
+
/**
|
|
88
|
+
* Initializes instances of Tabs.
|
|
89
|
+
* @param els HTML elements.
|
|
90
|
+
* @param options Component options.
|
|
91
|
+
*/
|
|
92
|
+
static init(els: HTMLElement | InitElements<MElement>, options: Partial<TabsOptions> = {}): Tabs | Tabs[] {
|
|
93
|
+
return super.init(els, options, Tabs);
|
|
94
|
+
}
|
|
51
95
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
96
|
+
static getInstance(el: HTMLElement): Tabs {
|
|
97
|
+
return (el as any).M_Tabs;
|
|
98
|
+
}
|
|
56
99
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
this._teardownNormalTabs();
|
|
65
|
-
}
|
|
66
|
-
(this.el as any).M_Tabs = undefined;
|
|
100
|
+
destroy() {
|
|
101
|
+
this._removeEventHandlers();
|
|
102
|
+
this._indicator.parentNode.removeChild(this._indicator);
|
|
103
|
+
if (this.options.swipeable) {
|
|
104
|
+
this._teardownSwipeableTabs();
|
|
67
105
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this._handleWindowResizeBound = this._handleWindowResize.bind(this);
|
|
71
|
-
window.addEventListener('resize', this._handleWindowResizeBound);
|
|
72
|
-
this._handleTabClickBound = this._handleTabClick.bind(this);
|
|
73
|
-
this.el.addEventListener('click', this._handleTabClickBound);
|
|
106
|
+
else {
|
|
107
|
+
this._teardownNormalTabs();
|
|
74
108
|
}
|
|
109
|
+
(this.el as any).M_Tabs = undefined;
|
|
110
|
+
}
|
|
75
111
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
/**
|
|
113
|
+
* The index of tab that is currently shown.
|
|
114
|
+
*/
|
|
115
|
+
get index(){ return this._index; }
|
|
80
116
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
117
|
+
_setupEventHandlers() {
|
|
118
|
+
window.addEventListener('resize', this._handleWindowResize);
|
|
119
|
+
this.el.addEventListener('click', this._handleTabClick);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_removeEventHandlers() {
|
|
123
|
+
window.removeEventListener('resize', this._handleWindowResize);
|
|
124
|
+
this.el.removeEventListener('click', this._handleTabClick);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_handleWindowResize = () => {
|
|
128
|
+
this._setTabsAndTabWidth();
|
|
129
|
+
if (this._tabWidth !== 0 && this._tabsWidth !== 0) {
|
|
130
|
+
this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
|
|
131
|
+
this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
|
|
87
132
|
}
|
|
133
|
+
}
|
|
88
134
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
135
|
+
_handleTabClick = (e: MouseEvent) => {
|
|
136
|
+
const tabLink = e.target as HTMLAnchorElement;
|
|
137
|
+
const tab = tabLink.parentElement;
|
|
138
|
+
// Handle click on tab link only
|
|
139
|
+
if (!tabLink || !tab.classList.contains('tab')) return;
|
|
140
|
+
// is disabled?
|
|
141
|
+
if (tab.classList.contains('disabled')) {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Act as regular link if target attribute is specified.
|
|
146
|
+
if (tabLink.hasAttribute('target')) return;
|
|
147
|
+
// Make the old tab inactive.
|
|
148
|
+
this._activeTabLink.classList.remove('active');
|
|
149
|
+
const _oldContent = this._content;
|
|
150
|
+
// Update the variables with the new link and content
|
|
105
151
|
|
|
106
152
|
this._activeTabLink = tabLink;
|
|
107
153
|
if (tabLink.hash)
|
|
@@ -112,53 +158,53 @@ export class Tabs extends Component {
|
|
|
112
158
|
const prevIndex = this._index;
|
|
113
159
|
this._index = Math.max(Array.from(this._tabLinks).indexOf(tabLink), 0);
|
|
114
160
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (typeof this.options.onShow === 'function')
|
|
120
|
-
this.options.onShow.call(this, this._content);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
if (this._content) {
|
|
125
|
-
this._content.style.display = 'block';
|
|
126
|
-
this._content.classList.add('active');
|
|
161
|
+
// Swap content
|
|
162
|
+
if (this.options.swipeable) {
|
|
163
|
+
if (this._tabsCarousel) {
|
|
164
|
+
this._tabsCarousel.set(this._index, () => {
|
|
127
165
|
if (typeof this.options.onShow === 'function')
|
|
128
166
|
this.options.onShow.call(this, this._content);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
if (this._content) {
|
|
171
|
+
this._content.style.display = 'block';
|
|
172
|
+
this._content.classList.add('active');
|
|
173
|
+
if (typeof this.options.onShow === 'function')
|
|
174
|
+
this.options.onShow.call(this, this._content);
|
|
175
|
+
if (_oldContent && _oldContent !== this._content) {
|
|
176
|
+
_oldContent.style.display = 'none';
|
|
177
|
+
_oldContent.classList.remove('active');
|
|
133
178
|
}
|
|
134
179
|
}
|
|
135
|
-
// Update widths after content is swapped (scrollbar bugfix)
|
|
136
|
-
this._setTabsAndTabWidth();
|
|
137
|
-
this._animateIndicator(prevIndex);
|
|
138
|
-
e.preventDefault();
|
|
139
180
|
}
|
|
181
|
+
// Update widths after content is swapped (scrollbar bugfix)
|
|
182
|
+
this._setTabsAndTabWidth();
|
|
183
|
+
this._animateIndicator(prevIndex);
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
}
|
|
140
186
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
187
|
+
_createIndicator() {
|
|
188
|
+
const indicator = document.createElement('li');
|
|
189
|
+
indicator.classList.add('indicator');
|
|
190
|
+
this.el.appendChild(indicator);
|
|
191
|
+
this._indicator = indicator;
|
|
192
|
+
this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
|
|
193
|
+
this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
|
|
194
|
+
}
|
|
149
195
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
_setupActiveTabLink() {
|
|
197
|
+
// If the location.hash matches one of the links, use that as the active tab.
|
|
198
|
+
this._activeTabLink = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === location.hash);
|
|
199
|
+
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
|
200
|
+
if (!this._activeTabLink) {
|
|
201
|
+
this._activeTabLink = this.el.querySelector('li.tab a.active');
|
|
202
|
+
}
|
|
203
|
+
if (this._activeTabLink.length === 0) {
|
|
204
|
+
this._activeTabLink = this.el.querySelector('li.tab a');
|
|
205
|
+
}
|
|
206
|
+
Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
|
|
207
|
+
this._activeTabLink.classList.add('active');
|
|
162
208
|
|
|
163
209
|
this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
|
|
164
210
|
if (this._activeTabLink && this._activeTabLink.hash) {
|
|
@@ -167,10 +213,10 @@ export class Tabs extends Component {
|
|
|
167
213
|
}
|
|
168
214
|
}
|
|
169
215
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
216
|
+
_setupSwipeableTabs() {
|
|
217
|
+
// Change swipeable according to responsive threshold
|
|
218
|
+
if (window.innerWidth > this.options.responsiveThreshold)
|
|
219
|
+
this.options.swipeable = false;
|
|
174
220
|
|
|
175
221
|
const tabsContent = [];
|
|
176
222
|
this._tabLinks.forEach(a => {
|
|
@@ -181,113 +227,121 @@ export class Tabs extends Component {
|
|
|
181
227
|
}
|
|
182
228
|
});
|
|
183
229
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
230
|
+
// Create Carousel-Wrapper around Tab-Contents
|
|
231
|
+
const tabsWrapper = document.createElement('div');
|
|
232
|
+
tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
|
|
233
|
+
|
|
234
|
+
// Wrap around
|
|
235
|
+
tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
|
|
236
|
+
tabsContent.forEach(tabContent => {
|
|
237
|
+
tabsWrapper.appendChild(tabContent);
|
|
238
|
+
tabContent.style.display = '';
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Keep active tab index to set initial carousel slide
|
|
242
|
+
const tab = this._activeTabLink.parentElement;
|
|
243
|
+
const activeTabIndex = Array.from(tab.parentNode.children).indexOf(tab);
|
|
244
|
+
|
|
245
|
+
this._tabsCarousel = Carousel.init(tabsWrapper, {
|
|
246
|
+
fullWidth: true,
|
|
247
|
+
noWrap: true,
|
|
248
|
+
onCycleTo: (item) => {
|
|
249
|
+
const prevIndex = this._index;
|
|
250
|
+
this._index = Array.from(item.parentNode.children).indexOf(item);
|
|
251
|
+
this._activeTabLink.classList.remove('active');
|
|
252
|
+
this._activeTabLink = Array.from(this._tabLinks)[this._index];
|
|
253
|
+
this._activeTabLink.classList.add('active');
|
|
254
|
+
this._animateIndicator(prevIndex);
|
|
255
|
+
if (typeof this.options.onShow === 'function')
|
|
256
|
+
this.options.onShow.call(this, this._content);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
// Set initial carousel slide to active tab
|
|
260
|
+
this._tabsCarousel.set(activeTabIndex);
|
|
261
|
+
}
|
|
216
262
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
263
|
+
_teardownSwipeableTabs() {
|
|
264
|
+
const tabsWrapper = this._tabsCarousel.el;
|
|
265
|
+
this._tabsCarousel.destroy();
|
|
266
|
+
// Unwrap
|
|
267
|
+
tabsWrapper.after(tabsWrapper.children);
|
|
268
|
+
tabsWrapper.remove();
|
|
269
|
+
}
|
|
224
270
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
271
|
+
_setupNormalTabs() {
|
|
272
|
+
// Hide Tabs Content
|
|
273
|
+
Array.from(this._tabLinks).forEach((a) => {
|
|
274
|
+
if (a === this._activeTabLink) return;
|
|
275
|
+
if ((<HTMLAnchorElement>a).hash) {
|
|
276
|
+
const currContent = document.querySelector((<HTMLAnchorElement>a).hash);
|
|
277
|
+
if (currContent) (<HTMLElement>currContent).style.display = 'none';
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
235
281
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
282
|
+
_teardownNormalTabs() {
|
|
283
|
+
// show Tabs Content
|
|
284
|
+
this._tabLinks.forEach((a) => {
|
|
285
|
+
if (a.hash) {
|
|
286
|
+
const currContent = document.querySelector(a.hash) as HTMLElement;
|
|
287
|
+
if (currContent) currContent.style.display = '';
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
245
291
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
292
|
+
_setTabsAndTabWidth() {
|
|
293
|
+
this._tabsWidth = this.el.getBoundingClientRect().width;
|
|
294
|
+
this._tabWidth = Math.max(this._tabsWidth, this.el.scrollWidth) / this._tabLinks.length;
|
|
295
|
+
}
|
|
250
296
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
297
|
+
_calcRightPos(el) {
|
|
298
|
+
return Math.ceil(this._tabsWidth - el.offsetLeft - el.getBoundingClientRect().width);
|
|
299
|
+
}
|
|
254
300
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
301
|
+
_calcLeftPos(el) {
|
|
302
|
+
return Math.floor(el.offsetLeft);
|
|
303
|
+
}
|
|
258
304
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Recalculate tab indicator position. This is useful when
|
|
307
|
+
* the indicator position is not correct.
|
|
308
|
+
*/
|
|
309
|
+
updateTabIndicator() {
|
|
310
|
+
this._setTabsAndTabWidth();
|
|
311
|
+
this._animateIndicator(this._index);
|
|
312
|
+
}
|
|
263
313
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
314
|
+
_animateIndicator(prevIndex) {
|
|
315
|
+
let leftDelay = 0, rightDelay = 0;
|
|
316
|
+
|
|
317
|
+
if (this._index - prevIndex >= 0)
|
|
318
|
+
leftDelay = 90;
|
|
319
|
+
else
|
|
320
|
+
rightDelay = 90;
|
|
321
|
+
|
|
322
|
+
const animOptions = {
|
|
323
|
+
targets: this._indicator,
|
|
324
|
+
left: {
|
|
325
|
+
value: this._calcLeftPos(this._activeTabLink),
|
|
326
|
+
delay: leftDelay
|
|
327
|
+
},
|
|
328
|
+
right: {
|
|
329
|
+
value: this._calcRightPos(this._activeTabLink),
|
|
330
|
+
delay: rightDelay
|
|
331
|
+
},
|
|
332
|
+
duration: this.options.duration,
|
|
333
|
+
easing: 'easeOutQuad'
|
|
334
|
+
};
|
|
335
|
+
anim.remove(this._indicator);
|
|
336
|
+
anim(animOptions);
|
|
337
|
+
}
|
|
288
338
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Show tab content that corresponds to the tab with the id.
|
|
341
|
+
* @param tabId The id of the tab that you want to switch to.
|
|
342
|
+
*/
|
|
343
|
+
select(tabId: string) {
|
|
344
|
+
const tab = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === '#'+tabId);
|
|
345
|
+
if (tab) (<HTMLAnchorElement>tab).click();
|
|
293
346
|
}
|
|
347
|
+
}
|