Skip to content

Commit d9f3857

Browse files
committed
chore: loading icon
1 parent 59c13af commit d9f3857

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

public/imgs/meidi.png

1.94 KB
Loading

src/app.css

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,35 @@ body {
3838
}
3939
}
4040

41+
42+
.loading-container {
43+
position: relative;
44+
width: 90%;
45+
max-width: 600px;
46+
height: 8px;
47+
border-radius: 6px;
48+
}
49+
50+
#loading-bar {
51+
width: 0%;
52+
height: 100%;
53+
background-color: #ffe65a;
54+
transition: width 0.2s ease;
55+
height: 100%;
56+
border-radius: 4px;
57+
position: relative;
58+
}
59+
60+
#loading-bar::after {
61+
content: "";
62+
position: absolute;
63+
top: -65px;
64+
right: -15px;
65+
width: 60px;
66+
height: 60px;
67+
background: url("/imgs/meidi.png") no-repeat center / contain;
68+
}
69+
4170
#loading-overlay {
4271
position: fixed;
4372
top: 0;
@@ -52,19 +81,16 @@ body {
5281
transition: opacity 0.1s ease-out;
5382
}
5483

55-
.loading-container {
56-
width: 80%;
57-
max-width: 400px;
58-
height: 8px;
59-
border-radius: 6px;
60-
overflow: hidden;
84+
85+
86+
@keyframes dog-jump {
87+
0% { transform: translateY(0); }
88+
30% { transform: translateY(-20px); }
89+
60% { transform: translateY(0); }
90+
80% { transform: translateY(-10px); }
91+
100% { transform: translateY(0); }
6192
}
6293

63-
#loading-bar {
64-
width: 100%;
65-
height: 100%;
66-
background-color: #ffe65a;
67-
transform: scaleX(0);
68-
transform-origin: left;
69-
transition: transform 0.2s ease;
94+
#loading-bar.done::after {
95+
animation: dog-jump 0.6s ease-out;
7096
}

src/lib/BookScene.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,20 @@ export class BookScene {
102102

103103
this.loadingManager.onProgress = (url, itemsLoaded, itemsTotal) => {
104104
const progressRatio = itemsLoaded / itemsTotal;
105-
(loadingBar as HTMLElement).style.transform = `scaleX(${ progressRatio })`;
105+
(loadingBar as HTMLElement).style.width = `${ progressRatio * 100 }%`;
106106
};
107107

108108
this.loadingManager.onLoad = () => {
109+
(loadingBar as HTMLElement).classList.add("done");
110+
109111
setTimeout(() => {
110112
this.renderable = true;
111113
}, 200);
112114

113115
gsap.to(loadingOverlay, {
114116
opacity: 0,
115-
duration: 1,
117+
duration: 0.3,
118+
delay: 0.3,
116119
onComplete: () => {
117120
loadingOverlay.style.visibility = 'hidden';
118121
}

src/lib/IconManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class IconManager {
324324
const photoCount = assets.media[get(currentPage)]?.photo || 0;
325325
if (photoCount > 0) {
326326
const randomIndex = Math.floor(Math.random() * photoCount) + 1;
327-
const imagePath = `/imgs/${ this.pageId }/${ randomIndex }.png`;
327+
const imagePath = `imgs/${ this.pageId }/${ randomIndex }.png`;
328328
this.showPhoto(imagePath);
329329
}
330330
}

0 commit comments

Comments
 (0)