forked from JVSC99/preloaderJSLottie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreloader.js
49 lines (44 loc) · 1.28 KB
/
preloader.js
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
const overlay = document.createElement('div');
overlay.id = 'loader';
overlay.style.cssText = `
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.7);
z-index: 999;
`;
const lottieContainer = document.createElement('div');
lottieContainer.id = 'lottieContainer';
lottieContainer.style.cssText = `
max-width: 100%;
max-height: 100%;
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
`;
lottieContainer.style.display = 'none';
document.body.appendChild(overlay);
document.body.appendChild(lottieContainer);
function hideOverlay() {
overlay.style.display = 'none';
lottieContainer.style.display = 'block';
// Substitua pela URL direta do seu arquivo JSON do Lottie.
lottie.loadAnimation({
container: lottieContainer,
renderer: 'svg', // ou 'canvas' se preferir
loop: true,
autoplay: true,
path: 'https://gilbertorosendo.github.io/preloaderJSLottie/Animation-1725556783538.json',
});
}
document.addEventListener('DOMContentLoaded', () => {
hideOverlay(); // Teste sem o setTimeout
});
window.addEventListener('load', hideOverlay);