-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
50 lines (39 loc) · 1.27 KB
/
app.js
File metadata and controls
50 lines (39 loc) · 1.27 KB
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
import {setDimensions, animate} from './particles.js';
const splashScreen = document.querySelector('.splash__screen')
const splashLeft = document.querySelector('.left');
const splashRight = document.querySelector('.right');
const progressBar = document.querySelector('.progress__bar');
const percentage = document.querySelector('.percentage');
let loading = true;
window.addEventListener('resize', setDimensions)
setDimensions()
animate()
async function setup(){
setTimeout(() => {
progressBar.style.height = '40%'
},2000);
setTimeout(() => {
progressBar.style.height = '80%'
},4000);
setTimeout(() => {
progressBar.style.height = '100%'
},5000);
setTimeout(() => {
splashLeft.classList.add('active');
splashRight.classList.add('active');
progressBar.classList.add('complete')
splashScreen.classList.add('complete')
loading = false
},6000);
}
function percentageTracker(){
if(loading){
let {height,top} = progressBar.getBoundingClientRect()
let p = Math.ceil((height / window.innerHeight) * 100);
percentage.textContent = `${p}%`;
percentage.style.transform = `translateY(calc(${top - window.innerHeight}px)`;
requestAnimationFrame(percentageTracker)
}
}
setup()
percentageTracker()