-
Notifications
You must be signed in to change notification settings - Fork 12
/
Fading.ts
76 lines (69 loc) · 1.52 KB
/
Fading.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* Static class for screen fading
*/
export abstract class Fading {
/**
* Gets whether the screen is faded in
*
* @returns True or false
*/
public static get IsFadedIn(): boolean {
return IsScreenFadedIn();
}
/**
* Gets whether the screen is faded out
*
* @returns True or false
*/
public static get IsFadedOut(): boolean {
return IsScreenFadedOut();
}
/**
* Gets whether the screen is currently fading in
*
* @returns True or false
*/
public static get IsFadingIn(): boolean {
return IsScreenFadingIn();
}
/**
* Gets whether the screen is currently fading out
*
* @returns True or false
*/
public static get IsFadingOut(): boolean {
return IsScreenFadingOut();
}
/**
* Fade in the screen for a certain duration.
*
* @param duration Time to fade in
*/
public static fadeIn(duration: number): Promise<void> {
return new Promise(resolve => {
DoScreenFadeIn(duration);
const interval = setInterval(() => {
if (this.IsFadedIn) {
clearInterval(interval);
resolve();
}
}, 0);
});
}
/**
* Fade out the screen for a certain duration.
*
* @param duration Time to fade out
*/
public static fadeOut(duration: number): Promise<void> {
return new Promise(resolve => {
DoScreenFadeOut(duration);
const interval = setInterval(() => {
if (this.IsFadedOut) {
clearInterval(interval);
resolve();
}
}, 0);
});
}
}