Skip to content

Commit 800c27f

Browse files
committed
feat(front): slowly render cards to improve performance
1 parent d3ec814 commit 800c27f

File tree

3 files changed

+98
-87
lines changed

3 files changed

+98
-87
lines changed

dev/js/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function createLightbox (id) {
135135

136136
fetch('themes.json')
137137
.then(data => data.json())
138-
.then(data => {
138+
.then(async data => {
139139

140140
data = Object.entries(data)
141141

@@ -183,10 +183,8 @@ function createLightbox (id) {
183183
*/
184184
case 'random':
185185
for (let i = data.length - 1; i > 0; i--) {
186-
187186
const j = Math.floor(Math.random() * (i + 1));
188187
[data[i], data[j]] = [data[j], data[i]]
189-
190188
}
191189
break
192190

@@ -202,6 +200,7 @@ function createLightbox (id) {
202200
{
203201
const card = new Card(entry, index)
204202
card.render(outputContainer)
203+
await new Promise(r => setTimeout(r, 666));
205204
}
206205

207206
})

0 commit comments

Comments
 (0)