feat(gallery.ts): change image source to a data attribute and dynamically load it when the image is visible

This commit is contained in:
Sped0n
2023-10-30 17:47:06 +08:00
parent b5aae19c70
commit 071f53071e
3 changed files with 26 additions and 7 deletions

View File

@@ -62,9 +62,9 @@ function createCollection(ijs: ImageJSON[]): void {
const y = i !== 0 ? getRandom(-30, 30) : 0
// element
const e = document.createElement('img')
e.src = ij.url
e.height = ij.imgH
e.width = ij.imgW
e.src = ij.loUrl
e.height = ij.loImgH
e.width = ij.loImgW
e.alt = 'image'
e.style.transform = `translate3d(${x}%, ${y - 50}%, 0)`
collection.append(e)