forked from zoontek/react-native-bootsplash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNativeRNBootSplash.web.ts
46 lines (38 loc) · 1.14 KB
/
NativeRNBootSplash.web.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
import type { Spec } from "./NativeRNBootSplash";
function resolveAfter(delay: number) {
return new Promise((resolve) => setTimeout(resolve, delay));
}
function removeNode(node: Node | null) {
const parent = node?.parentNode;
if (node != null && parent != null) {
parent.removeChild(node);
}
}
export default {
getConstants: () => ({
logoSizeRatio: 1,
navigationBarHeight: 0,
statusBarHeight: 0,
}),
hide: (fade) =>
document.fonts.ready.then(() => {
const container = document.getElementById("bootsplash");
const style = document.getElementById("bootsplash-style");
if (container == null || !fade) {
removeNode(container);
removeNode(style);
} else {
container.style.transitionProperty = "opacity";
container.style.transitionDuration = "250ms";
container.style.opacity = "0";
return resolveAfter(250).then(() => {
removeNode(container);
removeNode(style);
});
}
}),
isVisible: () => {
const container = document.getElementById("bootsplash");
return Promise.resolve(container != null);
},
} satisfies Spec;