Skip to content

Commit

Permalink
feat: fix progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Oct 5, 2023
1 parent 5b31d24 commit 66a0778
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,12 @@ <h1 class="font-esthetic my-4" style="font-size: 2.5rem;">Wahyu & Riski</h1>
<!-- Loading page -->
<div class="loading-page" id="loading" style="opacity: 1;">
<div class="d-flex justify-content-center align-items-center" style="height: 100vh !important;">
<div class="progress w-75" role="progressbar">
<div class="progress-bar" id="bar" style="width: 0%">0%</div>
<div class="text-center w-75">
<img class="img-fluid mb-3" src="./assets/images/icon-192x192.png" alt="icon" style="width: 3.5rem;">
<div class="progress" role="progressbar" style="height: 0.5rem;">
<div class="progress-bar" id="bar" style="width: 0%"></div>
</div>
<small class="mt-1" id="progress-info">Loading asset</small>
</div>
</div>
</div>
Expand Down
15 changes: 11 additions & 4 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const progressBar = (() => {
const bar = document.getElementById('bar');
const assets = document.querySelectorAll('img');

let totalAssets = assets.length;
Expand All @@ -8,11 +7,19 @@ const progressBar = (() => {
const progress = () => {
const progressPercentage = Math.min((loadedAssets / totalAssets) * 100, 100);

bar.style.width = progressPercentage.toString() + "%";
bar.innerText = `${progressPercentage.toFixed(0)}%`;
document.getElementById('bar').style.width = progressPercentage.toString() + "%";
document.getElementById('progress-info').innerText = `Loading asset (${loadedAssets}) [${progressPercentage.toFixed(0)}%]`;

if (loadedAssets == totalAssets) {
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}

document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;

window.scrollTo(0, 0);

tamu();
opacity('loading');
}
Expand Down Expand Up @@ -823,6 +830,7 @@ const buka = async () => {
opacity('welcome');
document.getElementById('tombol-musik').style.display = 'block';
AOS.init();
audio.play();

await confetti({
origin: { y: 0.8 },
Expand All @@ -832,7 +840,6 @@ const buka = async () => {

await login();
timer();
audio.play();
};

// OK
Expand Down

0 comments on commit 66a0778

Please sign in to comment.