@appartmint/mint 1.2.2 → 1.2.4
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/README.md +3 -3
- package/dist/css/mint.css +85 -44
- 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 +124 -124
- package/dist/js/imports/components/index.d.ts +4 -4
- package/dist/js/imports/enums/index.d.ts +4 -4
- package/dist/js/imports/enums/side.d.ts +9 -9
- package/dist/js/imports/index.d.ts +7 -7
- package/dist/js/imports/models/color.d.ts +31 -31
- package/dist/js/imports/models/file.d.ts +20 -20
- package/dist/js/imports/models/index.d.ts +9 -9
- package/dist/js/imports/models/item.d.ts +70 -70
- package/dist/js/imports/models/minify.d.ts +11 -11
- package/dist/js/imports/models/page.d.ts +17 -17
- package/dist/js/imports/models/recaptcha.d.ts +8 -8
- package/dist/js/imports/util/display.d.ts +24 -24
- package/dist/js/imports/util/event.d.ts +40 -40
- package/dist/js/imports/util/icon.d.ts +28 -28
- package/dist/js/imports/util/index.d.ts +14 -14
- package/dist/js/imports/util/list.d.ts +22 -22
- package/dist/js/imports/util/math.d.ts +13 -13
- package/dist/js/imports/util/object.d.ts +77 -77
- package/dist/js/imports/util/scroll.d.ts +22 -22
- package/dist/js/imports/util/selectors.d.ts +121 -121
- package/dist/js/imports/util/settings.d.ts +38 -38
- package/dist/js/imports/util/text.d.ts +39 -39
- package/dist/js/imports/util/window.d.ts +11 -11
- package/dist/js/index.d.ts +9 -9
- package/dist/js/index.js +351 -351
- 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/_index.scss +10 -10
- package/src/scss/imports/components/_cards.scss +1 -1
- package/src/scss/imports/components/_index.scss +16 -16
- package/src/scss/imports/global/_grid.scss +9 -0
- package/src/scss/imports/global/_icons.scss +6 -6
- package/src/scss/imports/global/_index.scss +2 -0
- package/src/scss/imports/global/_structure.scss +9 -0
- package/src/scss/imports/util/_index.scss +9 -9
- package/src/ts/imports/enums/side.ts +9 -9
- package/src/ts/imports/models/color.ts +96 -96
- package/src/ts/imports/util/display.ts +72 -72
- package/src/ts/imports/util/event.ts +93 -93
- package/src/ts/imports/util/math.ts +17 -17
- package/src/ts/imports/util/window.ts +14 -14
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/// _index.scss - Forward all overrides
|
|
2
|
-
/// @author App Art Mint LLC
|
|
3
|
-
///
|
|
4
|
-
/// @group Index
|
|
5
|
-
@charset 'utf-8';
|
|
6
|
-
|
|
7
|
-
/// Imports
|
|
8
|
-
@use './backgrounds';
|
|
9
|
-
@use './buttons';
|
|
10
|
-
@use './cards';
|
|
11
|
-
@use './embed';
|
|
12
|
-
@use './footer';
|
|
13
|
-
@use './header';
|
|
14
|
-
@use './image';
|
|
15
|
-
@use './recaptcha';
|
|
16
|
-
@use './tables';
|
|
1
|
+
/// _index.scss - Forward all overrides
|
|
2
|
+
/// @author App Art Mint LLC
|
|
3
|
+
///
|
|
4
|
+
/// @group Index
|
|
5
|
+
@charset 'utf-8';
|
|
6
|
+
|
|
7
|
+
/// Imports
|
|
8
|
+
@use './backgrounds';
|
|
9
|
+
@use './buttons';
|
|
10
|
+
@use './cards';
|
|
11
|
+
@use './embed';
|
|
12
|
+
@use './footer';
|
|
13
|
+
@use './header';
|
|
14
|
+
@use './image';
|
|
15
|
+
@use './recaptcha';
|
|
16
|
+
@use './tables';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// Icon styles
|
|
2
|
-
i {
|
|
3
|
-
&.fa-envelope {
|
|
4
|
-
transform: translateY(5%);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
/// Icon styles
|
|
2
|
+
i {
|
|
3
|
+
&.fa-envelope {
|
|
4
|
+
transform: translateY(5%);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
@@ -72,3 +72,12 @@
|
|
|
72
72
|
#{class(right)} {
|
|
73
73
|
float: right;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
#{class(full-page)} {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
min-height: calc(100vh - css-var(header-height));
|
|
82
|
+
min-height: calc(100dvh - css-var(header-height));
|
|
83
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// _index.scss - Forward all overrides
|
|
2
|
-
/// @author App Art Mint LLC
|
|
3
|
-
///
|
|
4
|
-
/// @group Index
|
|
5
|
-
@charset 'utf-8';
|
|
6
|
-
|
|
7
|
-
/// Imports
|
|
8
|
-
@forward './util';
|
|
9
|
-
@forward './vars';
|
|
1
|
+
/// _index.scss - Forward all overrides
|
|
2
|
+
/// @author App Art Mint LLC
|
|
3
|
+
///
|
|
4
|
+
/// @group Index
|
|
5
|
+
@charset 'utf-8';
|
|
6
|
+
|
|
7
|
+
/// Imports
|
|
8
|
+
@forward './util';
|
|
9
|
+
@forward './vars';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Side Enum
|
|
3
|
-
*/
|
|
4
|
-
export enum EMintSide {
|
|
5
|
-
Top,
|
|
6
|
-
Right,
|
|
7
|
-
Bottom,
|
|
8
|
-
Left
|
|
9
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Side Enum
|
|
3
|
+
*/
|
|
4
|
+
export enum EMintSide {
|
|
5
|
+
Top,
|
|
6
|
+
Right,
|
|
7
|
+
Bottom,
|
|
8
|
+
Left
|
|
9
|
+
};
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color
|
|
3
|
-
*/
|
|
4
|
-
export class mintColor {
|
|
5
|
-
protected static hexBase: number = 16;
|
|
6
|
-
protected static hexMax: string = 'FF';
|
|
7
|
-
public r: number;
|
|
8
|
-
public g: number;
|
|
9
|
-
public b: number;
|
|
10
|
-
public a: number;
|
|
11
|
-
|
|
12
|
-
constructor (args: {[key: string]: number | string}) {
|
|
13
|
-
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
-
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
-
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
-
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
-
if (typeof args.color === 'string') {
|
|
18
|
-
this.stringConstructor(args.color);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Constructor from a string argument
|
|
24
|
-
*/
|
|
25
|
-
protected stringConstructor (str: string) : void {
|
|
26
|
-
if (str.startsWith('#')) {
|
|
27
|
-
this.hexConstructor(str);
|
|
28
|
-
} else {
|
|
29
|
-
if (~str.indexOf('linear-gradient')) {
|
|
30
|
-
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
-
}
|
|
32
|
-
this.rgbConstructor(str);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructor from a hex argument
|
|
38
|
-
*/
|
|
39
|
-
protected hexConstructor (hex: string) : void {
|
|
40
|
-
switch (hex.length) {
|
|
41
|
-
case 1:
|
|
42
|
-
case 5:
|
|
43
|
-
case 6:
|
|
44
|
-
return;
|
|
45
|
-
case 2:
|
|
46
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
-
break;
|
|
48
|
-
case 3:
|
|
49
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
-
break;
|
|
51
|
-
case 4:
|
|
52
|
-
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
-
break;
|
|
54
|
-
case 7:
|
|
55
|
-
hex += mintColor.hexMax;
|
|
56
|
-
break;
|
|
57
|
-
case 8:
|
|
58
|
-
hex += hex[hex.length - 1];
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
hex = hex.substring(0, 9);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
-
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
-
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
-
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Constructor from an rgba argument
|
|
72
|
-
*/
|
|
73
|
-
protected rgbConstructor (rgb: string) : void {
|
|
74
|
-
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
-
if (match) {
|
|
76
|
-
this.r = parseInt(match[1]);
|
|
77
|
-
this.g = parseInt(match[2]);
|
|
78
|
-
this.b = parseInt(match[3]);
|
|
79
|
-
this.a = parseFloat(match[4]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns the perceived brightness of the color
|
|
85
|
-
*/
|
|
86
|
-
getBrightness () : number {
|
|
87
|
-
if (this.a === 0) {
|
|
88
|
-
return 262;
|
|
89
|
-
}
|
|
90
|
-
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
-
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
-
}
|
|
93
|
-
return -1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export default mintColor;
|
|
1
|
+
/**
|
|
2
|
+
* Color
|
|
3
|
+
*/
|
|
4
|
+
export class mintColor {
|
|
5
|
+
protected static hexBase: number = 16;
|
|
6
|
+
protected static hexMax: string = 'FF';
|
|
7
|
+
public r: number;
|
|
8
|
+
public g: number;
|
|
9
|
+
public b: number;
|
|
10
|
+
public a: number;
|
|
11
|
+
|
|
12
|
+
constructor (args: {[key: string]: number | string}) {
|
|
13
|
+
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
+
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
+
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
+
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
+
if (typeof args.color === 'string') {
|
|
18
|
+
this.stringConstructor(args.color);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constructor from a string argument
|
|
24
|
+
*/
|
|
25
|
+
protected stringConstructor (str: string) : void {
|
|
26
|
+
if (str.startsWith('#')) {
|
|
27
|
+
this.hexConstructor(str);
|
|
28
|
+
} else {
|
|
29
|
+
if (~str.indexOf('linear-gradient')) {
|
|
30
|
+
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
+
}
|
|
32
|
+
this.rgbConstructor(str);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Constructor from a hex argument
|
|
38
|
+
*/
|
|
39
|
+
protected hexConstructor (hex: string) : void {
|
|
40
|
+
switch (hex.length) {
|
|
41
|
+
case 1:
|
|
42
|
+
case 5:
|
|
43
|
+
case 6:
|
|
44
|
+
return;
|
|
45
|
+
case 2:
|
|
46
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
+
break;
|
|
48
|
+
case 3:
|
|
49
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
+
break;
|
|
51
|
+
case 4:
|
|
52
|
+
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
+
break;
|
|
54
|
+
case 7:
|
|
55
|
+
hex += mintColor.hexMax;
|
|
56
|
+
break;
|
|
57
|
+
case 8:
|
|
58
|
+
hex += hex[hex.length - 1];
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
hex = hex.substring(0, 9);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
+
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
+
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
+
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Constructor from an rgba argument
|
|
72
|
+
*/
|
|
73
|
+
protected rgbConstructor (rgb: string) : void {
|
|
74
|
+
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
+
if (match) {
|
|
76
|
+
this.r = parseInt(match[1]);
|
|
77
|
+
this.g = parseInt(match[2]);
|
|
78
|
+
this.b = parseInt(match[3]);
|
|
79
|
+
this.a = parseFloat(match[4]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns the perceived brightness of the color
|
|
85
|
+
*/
|
|
86
|
+
getBrightness () : number {
|
|
87
|
+
if (this.a === 0) {
|
|
88
|
+
return 262;
|
|
89
|
+
}
|
|
90
|
+
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
+
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
+
}
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export default mintColor;
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Imports
|
|
3
|
-
*/
|
|
4
|
-
import { EMintSide } from '../enums';
|
|
5
|
-
import { MintSettings } from './settings';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Handles the display of elements
|
|
9
|
-
*/
|
|
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
|
-
}
|
|
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
|
-
}
|
|
71
|
-
};
|
|
72
|
-
export default MintDisplay;
|
|
1
|
+
/**
|
|
2
|
+
* Imports
|
|
3
|
+
*/
|
|
4
|
+
import { EMintSide } from '../enums';
|
|
5
|
+
import { MintSettings } from './settings';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Handles the display of elements
|
|
9
|
+
*/
|
|
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
|
+
}
|
|
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
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export default MintDisplay;
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import MintSettings from "./settings";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Event helper functions
|
|
5
|
-
*/
|
|
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
|
-
}
|
|
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
|
-
}
|
|
92
|
-
};
|
|
93
|
-
export default MintEvent;
|
|
1
|
+
import MintSettings from "./settings";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event helper functions
|
|
5
|
+
*/
|
|
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
|
+
}
|
|
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
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export default MintEvent;
|