@appartmint/mint 0.15.9 → 1.0.0
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/dist/css/mint.css +18 -9
- package/dist/css/mint.css.map +1 -1
- package/dist/css/mint.min.css +1 -1
- package/dist/css/mint.min.css.map +1 -1
- package/dist/js/imports/components/header.d.ts +2 -2
- package/dist/js/imports/components/header.d.ts.map +1 -1
- package/dist/js/imports/components/index.d.ts +5 -0
- package/dist/js/imports/components/index.d.ts.map +1 -0
- package/dist/js/imports/enums/index.d.ts +5 -0
- package/dist/js/imports/enums/index.d.ts.map +1 -0
- package/dist/js/imports/{enum.d.ts → enums/side.d.ts} +2 -2
- package/dist/js/imports/enums/side.d.ts.map +1 -0
- package/dist/js/imports/index.d.ts +8 -0
- package/dist/js/imports/index.d.ts.map +1 -0
- package/dist/js/imports/models/index.d.ts +6 -0
- package/dist/js/imports/models/index.d.ts.map +1 -0
- package/dist/js/imports/models/item.d.ts +6 -6
- package/dist/js/imports/util/display.d.ts +20 -2
- package/dist/js/imports/util/display.d.ts.map +1 -1
- package/dist/js/imports/util/event.d.ts +36 -2
- package/dist/js/imports/util/event.d.ts.map +1 -1
- package/dist/js/imports/util/icon.d.ts +2 -2
- package/dist/js/imports/util/index.d.ts +15 -0
- package/dist/js/imports/util/index.d.ts.map +1 -0
- package/dist/js/imports/util/list.d.ts +2 -2
- package/dist/js/imports/util/math.d.ts +2 -2
- package/dist/js/imports/util/object.d.ts +2 -2
- package/dist/js/imports/util/scroll.d.ts +2 -2
- package/dist/js/imports/util/selectors.d.ts +2 -2
- package/dist/js/imports/util/settings.d.ts +2 -2
- package/dist/js/imports/util/settings.d.ts.map +1 -1
- package/dist/js/imports/util/text.d.ts +15 -2
- package/dist/js/imports/util/text.d.ts.map +1 -1
- package/dist/js/imports/util/window.d.ts +7 -2
- package/dist/js/imports/util/window.d.ts.map +1 -1
- package/dist/js/index.d.ts +1 -16
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +541 -475
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.min.js +1 -1
- package/dist/js/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/scss/imports/components/_footer.scss +1 -0
- package/src/scss/imports/components/_header.scss +10 -12
- package/src/scss/imports/global/_global.scss +10 -2
- package/src/scss/imports/global/_texture.scss +3 -0
- package/src/scss/imports/util/_vars.scss +2 -1
- package/src/ts/imports/components/header.ts +34 -29
- package/src/ts/imports/components/index.ts +4 -0
- package/src/ts/imports/enums/index.ts +4 -0
- package/src/ts/imports/{enum.ts → enums/side.ts} +1 -1
- package/src/ts/imports/index.ts +7 -0
- package/src/ts/imports/models/index.ts +5 -0
- package/src/ts/imports/models/item.ts +6 -6
- package/src/ts/imports/util/display.ts +67 -2
- package/src/ts/imports/util/event.ts +88 -2
- package/src/ts/imports/util/icon.ts +2 -2
- package/src/ts/imports/util/index.ts +14 -0
- package/src/ts/imports/util/list.ts +2 -2
- package/src/ts/imports/util/math.ts +2 -2
- package/src/ts/imports/util/object.ts +3 -3
- package/src/ts/imports/util/scroll.ts +2 -2
- package/src/ts/imports/util/selectors.ts +3 -3
- package/src/ts/imports/util/settings.ts +2 -3
- package/src/ts/imports/util/text.ts +43 -2
- package/src/ts/imports/util/window.ts +10 -3
- package/src/ts/index.ts +1 -25
- package/dist/js/imports/enum.d.ts.map +0 -1
- package/dist/js/util.d.ts +0 -78
- package/dist/js/util.d.ts.map +0 -1
- package/dist/js/util.js +0 -399
- package/dist/js/util.js.map +0 -1
- package/dist/js/util.min.js +0 -2
- package/dist/js/util.min.js.map +0 -1
- package/src/ts/util.ts +0 -209
|
@@ -167,7 +167,11 @@
|
|
|
167
167
|
&+ul {
|
|
168
168
|
display: flex !important;
|
|
169
169
|
height: auto !important;
|
|
170
|
-
margin-bottom:
|
|
170
|
+
margin-bottom: 3rem !important;
|
|
171
|
+
|
|
172
|
+
&>li:first-child {
|
|
173
|
+
font-size: 1.5em;
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
177
|
}
|
|
@@ -181,7 +185,11 @@
|
|
|
181
185
|
&+ul {
|
|
182
186
|
display: flex !important;
|
|
183
187
|
height: auto !important;
|
|
184
|
-
margin-bottom:
|
|
188
|
+
margin-bottom: 3rem;
|
|
189
|
+
|
|
190
|
+
&>li:first-child {
|
|
191
|
+
font-size: 1.5em;
|
|
192
|
+
}
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
}
|
|
@@ -213,16 +221,6 @@
|
|
|
213
221
|
li {
|
|
214
222
|
width: 100%;
|
|
215
223
|
}
|
|
216
|
-
|
|
217
|
-
#{$has-controls} {
|
|
218
|
-
&+ul {
|
|
219
|
-
margin-bottom: 3rem !important;
|
|
220
|
-
|
|
221
|
-
&>li:first-child {
|
|
222
|
-
font-size: 1.5em;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
224
|
}
|
|
227
225
|
}
|
|
228
226
|
}
|
|
@@ -75,13 +75,21 @@ main {
|
|
|
75
75
|
overflow: hidden;
|
|
76
76
|
z-index: 1000;
|
|
77
77
|
|
|
78
|
-
|
|
79
78
|
&>router-outlet {
|
|
80
79
|
flex-grow: 0;
|
|
81
80
|
|
|
82
81
|
&+* {
|
|
83
|
-
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
84
86
|
flex-grow: 1;
|
|
87
|
+
width: 100%;
|
|
88
|
+
|
|
89
|
+
&+:not(mint-footer) {
|
|
90
|
+
height: 0;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -152,8 +152,9 @@ $texture-padding: 1rem !default;
|
|
|
152
152
|
|
|
153
153
|
$texture-bg: null !default;
|
|
154
154
|
$texture-bg-size: cover !default;
|
|
155
|
-
$texture-bg-position:
|
|
155
|
+
$texture-bg-position: top !default;
|
|
156
156
|
$texture-blend: null !default;
|
|
157
|
+
$texture-filter: null !default;
|
|
157
158
|
$texture-opacity: 1 !default;
|
|
158
159
|
|
|
159
160
|
$texture-alt-bg: null !default;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Imports
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { EMintSide } from '../enums';
|
|
5
|
+
import {
|
|
6
|
+
MintDisplay,
|
|
7
|
+
MintEvent,
|
|
8
|
+
MintSelectors,
|
|
9
|
+
MintSettings,
|
|
10
|
+
MintWindow
|
|
11
|
+
} from '../util';
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Main header functionality
|
|
11
16
|
* @public
|
|
12
17
|
*/
|
|
13
|
-
export class
|
|
18
|
+
export class MintHeader {
|
|
14
19
|
/**
|
|
15
20
|
* Navbar settings
|
|
16
21
|
*/
|
|
17
22
|
settings: {[key: string]: any} = {
|
|
18
|
-
from:
|
|
23
|
+
from: EMintSide.Top,
|
|
19
24
|
fixed: true
|
|
20
25
|
};
|
|
21
26
|
|
|
@@ -42,7 +47,7 @@ export class mintHeader {
|
|
|
42
47
|
this.el.html = document.querySelector('html');
|
|
43
48
|
this.el.body = document.querySelector('body');
|
|
44
49
|
this.el.header = document.getElementById('mint-header');
|
|
45
|
-
this.el.mobileButton = this.el.header?.querySelector(
|
|
50
|
+
this.el.mobileButton = this.el.header?.querySelector(MintSelectors.controls('mint-wrapper')) || null;
|
|
46
51
|
this.el.wrapper = document.getElementById('mint-wrapper');
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -50,22 +55,22 @@ export class mintHeader {
|
|
|
50
55
|
* Adds events to the dom
|
|
51
56
|
*/
|
|
52
57
|
attachEvents () : void {
|
|
53
|
-
window.addEventListener('resize',
|
|
54
|
-
window.addEventListener('scroll',
|
|
58
|
+
window.addEventListener('resize', MintEvent.throttleEvent(this.eHandleResize.bind(this), MintSettings.delay.default));
|
|
59
|
+
window.addEventListener('scroll', MintEvent.throttleEvent(this.eHandleScroll.bind(this), MintSettings.delay.default, { trailing: false }));
|
|
55
60
|
|
|
56
|
-
let focusables = this.el.header?.querySelectorAll(
|
|
61
|
+
let focusables = this.el.header?.querySelectorAll(MintSelectors.focusable),
|
|
57
62
|
lastFocusable = focusables?.[focusables?.length - 1];
|
|
58
|
-
lastFocusable?.addEventListener('keydown',
|
|
63
|
+
lastFocusable?.addEventListener('keydown', MintEvent.throttleEvent(this.eWrapTab.bind(this)));
|
|
59
64
|
focusables?.forEach((focusable) => {
|
|
60
|
-
focusable.addEventListener('keydown',
|
|
65
|
+
focusable.addEventListener('keydown', MintEvent.throttleEvent(this.eHandleKeypress.bind(this)));
|
|
61
66
|
});
|
|
62
67
|
|
|
63
|
-
let menuButtons = this.el.wrapper?.querySelectorAll(
|
|
68
|
+
let menuButtons = this.el.wrapper?.querySelectorAll(MintSelectors.controls());
|
|
64
69
|
menuButtons?.forEach((menuButton) => {
|
|
65
|
-
menuButton.addEventListener('click',
|
|
70
|
+
menuButton.addEventListener('click', MintEvent.throttleEvent(this.eToggleMenu.bind(this), MintSettings.delay.slow, { trailing: false }));
|
|
66
71
|
});
|
|
67
72
|
|
|
68
|
-
this.el.mobileButton?.addEventListener('click',
|
|
73
|
+
this.el.mobileButton?.addEventListener('click', MintEvent.throttleEvent(this.eToggleMobileMenu.bind(this), MintSettings.delay.slow, { trailing: false }));
|
|
69
74
|
this.el.wrapper?.addEventListener('transitionend', this.eTransitionEnd.bind(this));
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -74,7 +79,7 @@ export class mintHeader {
|
|
|
74
79
|
*/
|
|
75
80
|
addClasses () : void {
|
|
76
81
|
this.el.header?.classList.remove('mint-top', 'mint-right', 'mint-bottom', 'mint-left');
|
|
77
|
-
this.el.header?.classList.add(`mint-${
|
|
82
|
+
this.el.header?.classList.add(`mint-${EMintSide[this.settings.from ?? 0].toLowerCase()}`);
|
|
78
83
|
|
|
79
84
|
if (this.settings.fixed) {
|
|
80
85
|
this.el.body?.classList.add('mint-fixed');
|
|
@@ -95,7 +100,7 @@ export class mintHeader {
|
|
|
95
100
|
this.el.mobileButton?.setAttribute('aria-expanded', ariaExpanded);
|
|
96
101
|
setTimeout(() => {
|
|
97
102
|
this.el.mobileButton?.setAttribute('aria-label', ariaLabel);
|
|
98
|
-
},
|
|
103
|
+
}, MintSettings.delay.fast);
|
|
99
104
|
|
|
100
105
|
if (open) {
|
|
101
106
|
if (this.settings.fixed !== true) {
|
|
@@ -108,7 +113,7 @@ export class mintHeader {
|
|
|
108
113
|
|
|
109
114
|
setTimeout(() => {
|
|
110
115
|
if (this.el.html) {
|
|
111
|
-
let isMobile =
|
|
116
|
+
let isMobile = MintWindow.width() <= MintSettings.break.sm,
|
|
112
117
|
overflow = 'auto';
|
|
113
118
|
|
|
114
119
|
if (this.settings.tray) {
|
|
@@ -120,7 +125,7 @@ export class mintHeader {
|
|
|
120
125
|
}
|
|
121
126
|
this.el.html.style.overflow = overflow;
|
|
122
127
|
}
|
|
123
|
-
}, this.settings.from ===
|
|
128
|
+
}, this.settings.from === EMintSide.Left ? MintSettings.delay.default : MintSettings.delay.instant);
|
|
124
129
|
|
|
125
130
|
if (this.el.wrapper) {
|
|
126
131
|
this.el.wrapper.style.display = 'flex';
|
|
@@ -161,9 +166,9 @@ export class mintHeader {
|
|
|
161
166
|
if (button && menu) {
|
|
162
167
|
button.setAttribute('aria-expanded', ariaExpanded);
|
|
163
168
|
if (open) {
|
|
164
|
-
|
|
169
|
+
MintDisplay.show(menu);
|
|
165
170
|
} else {
|
|
166
|
-
|
|
171
|
+
MintDisplay.hide(menu);
|
|
167
172
|
this.closeSubMenus(button);
|
|
168
173
|
}
|
|
169
174
|
}
|
|
@@ -183,7 +188,7 @@ export class mintHeader {
|
|
|
183
188
|
*/
|
|
184
189
|
closeSubMenus (button?: HTMLElement | null) : void {
|
|
185
190
|
let menu: HTMLElement | null | undefined = button?.nextElementSibling as HTMLElement,
|
|
186
|
-
subMenus: NodeListOf<HTMLElement> = menu?.querySelectorAll(
|
|
191
|
+
subMenus: NodeListOf<HTMLElement> = menu?.querySelectorAll(MintSelectors.subMenuButtons) as NodeListOf<HTMLElement>;
|
|
187
192
|
subMenus.forEach((child: HTMLElement) => {
|
|
188
193
|
// setMenu calls this function, so ignore subsub menus
|
|
189
194
|
if (child.parentElement?.parentElement === menu) {
|
|
@@ -198,7 +203,7 @@ export class mintHeader {
|
|
|
198
203
|
*/
|
|
199
204
|
closeSiblingMenus (button?: HTMLElement | null) : void {
|
|
200
205
|
let menu: HTMLElement | null | undefined = button?.parentElement as HTMLElement,
|
|
201
|
-
siblingMenus: NodeListOf<HTMLElement> = menu?.parentElement?.querySelectorAll(
|
|
206
|
+
siblingMenus: NodeListOf<HTMLElement> = menu?.parentElement?.querySelectorAll(MintSelectors.subMenuButtons) as NodeListOf<HTMLElement>;
|
|
202
207
|
siblingMenus.forEach((child: HTMLElement) => {
|
|
203
208
|
if (child !== button) {
|
|
204
209
|
this.setMenu(child);
|
|
@@ -210,7 +215,7 @@ export class mintHeader {
|
|
|
210
215
|
* Closes all submenus of the n4vbar
|
|
211
216
|
*/
|
|
212
217
|
closeAllMenus () : void {
|
|
213
|
-
let menuButtons: NodeListOf<HTMLElement> | undefined = this.el.wrapper?.querySelectorAll(
|
|
218
|
+
let menuButtons: NodeListOf<HTMLElement> | undefined = this.el.wrapper?.querySelectorAll(MintSelectors.subMenuButtons);
|
|
214
219
|
menuButtons?.forEach((menuButton: HTMLElement) => {
|
|
215
220
|
this.setMenu(menuButton);
|
|
216
221
|
});
|
|
@@ -229,7 +234,7 @@ export class mintHeader {
|
|
|
229
234
|
|
|
230
235
|
if (activeButton?.getAttribute('aria-controls') && activeMenu && !showing) {
|
|
231
236
|
activeButton.click();
|
|
232
|
-
let firstFocusable: HTMLElement | null = activeMenu.querySelector(
|
|
237
|
+
let firstFocusable: HTMLElement | null = activeMenu.querySelector(MintSelectors.focusable);
|
|
233
238
|
firstFocusable?.focus();
|
|
234
239
|
}
|
|
235
240
|
}
|
|
@@ -239,7 +244,7 @@ export class mintHeader {
|
|
|
239
244
|
*/
|
|
240
245
|
closeClosestMenu () : void {
|
|
241
246
|
let activeElement: HTMLElement | null = document.activeElement as HTMLElement | null,
|
|
242
|
-
activeMenu: HTMLElement | null = activeElement?.closest(
|
|
247
|
+
activeMenu: HTMLElement | null = activeElement?.closest(MintSelectors.subMenu) as HTMLElement | null,
|
|
243
248
|
activeButton: HTMLElement | null = activeMenu?.previousElementSibling ? activeMenu.previousElementSibling as HTMLElement : this.el.mobileButton;
|
|
244
249
|
if (activeElement?.getAttribute('aria-controls') && activeElement?.getAttribute('aria-expanded')?.toLowerCase() === 'true') {
|
|
245
250
|
activeButton = activeElement;
|
|
@@ -267,7 +272,7 @@ export class mintHeader {
|
|
|
267
272
|
*/
|
|
268
273
|
eHandleResize () : void {
|
|
269
274
|
let isOpen = this.el.mobileButton?.getAttribute('aria-expanded')?.toLowerCase() === 'true',
|
|
270
|
-
isMobile =
|
|
275
|
+
isMobile = MintWindow.width() <= MintSettings.break.sm,
|
|
271
276
|
overflow = 'auto';
|
|
272
277
|
|
|
273
278
|
if (isOpen) {
|
|
@@ -399,5 +404,5 @@ export class mintHeader {
|
|
|
399
404
|
this.el.wrapper.style.display = 'none';
|
|
400
405
|
}
|
|
401
406
|
};
|
|
402
|
-
}
|
|
403
|
-
export default
|
|
407
|
+
};
|
|
408
|
+
export default MintHeader;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @note - this class must be convertable with JSON
|
|
4
4
|
* - only add strings, numbers, booleans, arrays, and objects
|
|
5
5
|
*/
|
|
6
|
-
export class
|
|
6
|
+
export class MintItem {
|
|
7
7
|
/**
|
|
8
8
|
* Item settings
|
|
9
9
|
*/
|
|
@@ -32,7 +32,7 @@ export class mintItem {
|
|
|
32
32
|
category?: string;
|
|
33
33
|
type?: string;
|
|
34
34
|
unit?: string;
|
|
35
|
-
logo?:
|
|
35
|
+
logo?: MintItem;
|
|
36
36
|
icon?: string;
|
|
37
37
|
position?: string;
|
|
38
38
|
transform?: string;
|
|
@@ -59,8 +59,8 @@ export class mintItem {
|
|
|
59
59
|
*/
|
|
60
60
|
paragraphs?: string[] = [];
|
|
61
61
|
classes?: string[] = [];
|
|
62
|
-
items?:
|
|
63
|
-
images?:
|
|
64
|
-
buttons?:
|
|
62
|
+
items?: MintItem[] = [];
|
|
63
|
+
images?: MintItem[] = [];
|
|
64
|
+
buttons?: MintItem[] = [];
|
|
65
65
|
};
|
|
66
|
-
export default
|
|
66
|
+
export default MintItem;
|
|
@@ -1,7 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports
|
|
3
|
+
*/
|
|
4
|
+
import { EMintSide } from '../enums';
|
|
5
|
+
import { MintSettings } from './settings';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Handles the display of elements
|
|
3
9
|
*/
|
|
4
|
-
export abstract class
|
|
10
|
+
export abstract class MintDisplay {
|
|
11
|
+
/**
|
|
12
|
+
* Sets the element's height to its `innerHeight`, then to `auto` after a delay
|
|
13
|
+
* @param el - the element whose height will be set
|
|
14
|
+
* @param delay - the amount of time in milliseconds that the show animation will be active
|
|
15
|
+
* @param from - the side that the element is animating from
|
|
16
|
+
*/
|
|
17
|
+
static show (el?: HTMLElement | null, delay: number = MintSettings.delay.default, from: EMintSide = EMintSide.Top) : void {
|
|
18
|
+
if (el) {
|
|
19
|
+
el.style.display = '';
|
|
20
|
+
requestAnimationFrame(() => {
|
|
21
|
+
if (from === EMintSide.Top || from === EMintSide.Bottom) {
|
|
22
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
23
|
+
} else {
|
|
24
|
+
el.style.width = `${el.scrollWidth}px`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
if (from === EMintSide.Top || from === EMintSide.Bottom) {
|
|
29
|
+
el.style.height = 'auto';
|
|
30
|
+
} else {
|
|
31
|
+
el.style.width = 'auto';
|
|
32
|
+
}
|
|
33
|
+
}, delay);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
5
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Sets the element's height to 0
|
|
40
|
+
* @param el - the element whose height will be set
|
|
41
|
+
* @param delay - the amount of time in milliseconds that the show animation will be active
|
|
42
|
+
* @param from - the side that the element is animating from
|
|
43
|
+
*/
|
|
44
|
+
static hide (el?: HTMLElement | null, delay: number = MintSettings.delay.default, from: EMintSide = EMintSide.Top) : void {
|
|
45
|
+
if (el) {
|
|
46
|
+
let height = el.scrollHeight,
|
|
47
|
+
width = el.scrollWidth,
|
|
48
|
+
transition = el.style.transition;
|
|
49
|
+
el.style.transition = '';
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
if (from === EMintSide.Top || from === EMintSide.Bottom) {
|
|
52
|
+
el.style.height = `${height}px`;
|
|
53
|
+
} else {
|
|
54
|
+
el.style.width = `${width}px`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
el.style.transition = transition;
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
if (from === EMintSide.Top || from === EMintSide.Bottom) {
|
|
60
|
+
el.style.height = '0';
|
|
61
|
+
} else {
|
|
62
|
+
el.style.width = '0';
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
el.style.display = 'none';
|
|
68
|
+
}, delay);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
6
71
|
};
|
|
7
|
-
export default
|
|
72
|
+
export default MintDisplay;
|
|
@@ -1,7 +1,93 @@
|
|
|
1
|
+
import MintSettings from "./settings";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Event helper functions
|
|
3
5
|
*/
|
|
4
|
-
export abstract class
|
|
6
|
+
export abstract class MintEvent {
|
|
7
|
+
/**
|
|
8
|
+
* Ensures that a function `func` is run only after not being called for `wait` milliseconds
|
|
9
|
+
* @param func - the function to debounce
|
|
10
|
+
* @param wait - the amount of time to wait before running the function
|
|
11
|
+
* @returns - the debounced function
|
|
12
|
+
*/
|
|
13
|
+
static debounce (func: Function, wait: number = MintSettings.delay.default) : Function {
|
|
14
|
+
let timer: number;
|
|
15
|
+
return function (e: any) {
|
|
16
|
+
if (timer) {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
}
|
|
19
|
+
timer = setTimeout(func, wait, e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Ensures that a function `func` is run only after not being called for `wait` milliseconds
|
|
25
|
+
* @param func - the function to debounce
|
|
26
|
+
* @param wait - the amount of time to wait before running the function
|
|
27
|
+
* @returns - the debounced function as an EventListener
|
|
28
|
+
*/
|
|
29
|
+
static debounceEvent (func: Function, wait: number = MintSettings.delay.default) : EventListener {
|
|
30
|
+
return MintEvent.debounce(func, wait) as EventListener;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls
|
|
35
|
+
* @param func - the function to throttle
|
|
36
|
+
* @param wait - the amount of time between function calls
|
|
37
|
+
* @param options - leading and trailing options: default = \{ leading: true, trailing, true \}
|
|
38
|
+
* @returns - the throttled function
|
|
39
|
+
*/
|
|
40
|
+
static throttle (func: Function,
|
|
41
|
+
wait: number = MintSettings.delay.default,
|
|
42
|
+
options?: {[key: string]: boolean}) : Function {
|
|
43
|
+
let context: any, args: any, result: any,
|
|
44
|
+
timeout: number, previous: number = 0,
|
|
45
|
+
later: Function = function () {
|
|
46
|
+
previous = options?.leading === false ? 0 : new Date().getTime();
|
|
47
|
+
timeout = 0;
|
|
48
|
+
result = func.apply(context, args);
|
|
49
|
+
if (!timeout) {
|
|
50
|
+
context = args = null;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
throttled: Function = function (this: any): any {
|
|
54
|
+
let now: number = new Date().getTime();
|
|
55
|
+
if (!previous && options?.leading === false) {
|
|
56
|
+
previous = now;
|
|
57
|
+
}
|
|
58
|
+
let remaining: number = wait - now + previous;
|
|
59
|
+
context = this;
|
|
60
|
+
args = arguments;
|
|
61
|
+
if (remaining <= 0 || remaining > wait) {
|
|
62
|
+
if (timeout) {
|
|
63
|
+
clearTimeout(timeout);
|
|
64
|
+
timeout = 0;
|
|
65
|
+
}
|
|
66
|
+
previous = now;
|
|
67
|
+
result = func.apply(context, args);
|
|
68
|
+
if (!timeout) {
|
|
69
|
+
context = args = null;
|
|
70
|
+
}
|
|
71
|
+
} else if (!timeout && options?.trailing !== false) {
|
|
72
|
+
timeout = window.setTimeout(later, remaining);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return throttled;
|
|
78
|
+
}
|
|
5
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Ensures that a function `func` is called at most every `wait` milliseconds with optional leading and trailing calls
|
|
82
|
+
* @param func - the function to throttle
|
|
83
|
+
* @param wait - the amount of time between function calls
|
|
84
|
+
* @param options - leading and trailing options: default = \{ leading: true, trailing, true \}
|
|
85
|
+
* @returns - the throttled function as an EventListener
|
|
86
|
+
*/
|
|
87
|
+
static throttleEvent (func: Function,
|
|
88
|
+
wait: number = MintSettings.delay.default,
|
|
89
|
+
options?: {[key: string]: boolean}) : EventListener {
|
|
90
|
+
return MintEvent.throttle(func, wait, options) as EventListener;
|
|
91
|
+
}
|
|
6
92
|
};
|
|
7
|
-
export default
|
|
93
|
+
export default MintEvent;
|
|
@@ -6,7 +6,7 @@ import mintObject from "./object";
|
|
|
6
6
|
/**
|
|
7
7
|
* Icon helper functions
|
|
8
8
|
*/
|
|
9
|
-
export abstract class
|
|
9
|
+
export abstract class MintIcon {
|
|
10
10
|
/**
|
|
11
11
|
* Default icons
|
|
12
12
|
*/
|
|
@@ -64,4 +64,4 @@ export abstract class mintIcon {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
export default
|
|
67
|
+
export default MintIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forward all exports from the util directory
|
|
3
|
+
*/
|
|
4
|
+
export * from './display';
|
|
5
|
+
export * from './event';
|
|
6
|
+
export * from './icon';
|
|
7
|
+
export * from './list';
|
|
8
|
+
export * from './math';
|
|
9
|
+
export * from './object';
|
|
10
|
+
export * from './scroll';
|
|
11
|
+
export * from './selectors';
|
|
12
|
+
export * from './settings';
|
|
13
|
+
export * from './text';
|
|
14
|
+
export * from './window';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List functions for the util library
|
|
3
3
|
*/
|
|
4
|
-
export abstract class
|
|
4
|
+
export abstract class MintList {
|
|
5
5
|
/**
|
|
6
6
|
* Returns a copy of the provided list with the items in random order
|
|
7
7
|
* @param list - the list to shuffle
|
|
@@ -36,4 +36,4 @@ export abstract class mintList {
|
|
|
36
36
|
return list;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
export default
|
|
39
|
+
export default MintList;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Math functions for the util library
|
|
3
3
|
*/
|
|
4
|
-
export abstract class
|
|
4
|
+
export abstract class MintMath {
|
|
5
5
|
/**
|
|
6
6
|
* Get a random integer between min and max
|
|
7
7
|
* @param max Maximum value to return
|
|
@@ -14,4 +14,4 @@ export abstract class mintMath {
|
|
|
14
14
|
return Math.floor(Math.random() * (max - min) + min);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
export default
|
|
17
|
+
export default MintMath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Object functions for the util library
|
|
3
3
|
*/
|
|
4
|
-
export abstract class
|
|
4
|
+
export abstract class MintObject {
|
|
5
5
|
/**
|
|
6
6
|
* Returns true if the provided objects have the same entries
|
|
7
7
|
*/
|
|
@@ -52,7 +52,7 @@ export abstract class mintObject {
|
|
|
52
52
|
// If the children of the subset are subsets of the
|
|
53
53
|
// respective children of the superset, it is a superset
|
|
54
54
|
Object.keys(subset).forEach((key: string) => {
|
|
55
|
-
isSuperset = isSuperset &&
|
|
55
|
+
isSuperset = isSuperset && MintObject.isSuperset(superset[key], subset[key]);
|
|
56
56
|
});
|
|
57
57
|
return isSuperset;
|
|
58
58
|
}
|
|
@@ -198,4 +198,4 @@ export abstract class mintObject {
|
|
|
198
198
|
newObjects?.forEach(newObject => original.push(newObject));
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
|
-
export default
|
|
201
|
+
export default MintObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scroll functions
|
|
3
3
|
*/
|
|
4
|
-
export abstract class
|
|
4
|
+
export abstract class MintScroll {
|
|
5
5
|
/**
|
|
6
6
|
* Scroll to the top of the page
|
|
7
7
|
*/
|
|
@@ -38,4 +38,4 @@ export abstract class mintScroll {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
export default
|
|
41
|
+
export default MintScroll;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* CSS-selector helpers
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
-
export abstract class
|
|
5
|
+
export abstract class MintSelectors {
|
|
6
6
|
/**
|
|
7
7
|
* The library name that will be added as a prefix
|
|
8
8
|
*/
|
|
@@ -181,5 +181,5 @@ export abstract class mintSelectors {
|
|
|
181
181
|
} while (current);
|
|
182
182
|
return true;
|
|
183
183
|
}
|
|
184
|
-
}
|
|
185
|
-
export default
|
|
184
|
+
};
|
|
185
|
+
export default MintSelectors;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Settings management
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
-
export abstract class
|
|
5
|
+
export abstract class MintSettings {
|
|
6
6
|
/**
|
|
7
7
|
* Value added to all delay variables
|
|
8
8
|
*/
|
|
@@ -82,5 +82,4 @@ export abstract class mintSettings {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
export default mintSettings;
|
|
85
|
+
export default MintSettings;
|