now creation of image element can be achieved by createImgElement function in utils.ts

This commit is contained in:
Spedon
2023-03-14 02:02:56 +08:00
parent 38d1a8ab38
commit 9a7281f6da
2 changed files with 18 additions and 7 deletions

View File

@@ -79,3 +79,12 @@ export const center = (e: HTMLDivElement): void => {
e.style.top = 'calc((100% - 31px) / 2 + 31px)'
}
}
export function createImgElement(input: ImageData): HTMLImageElement {
const img = document.createElement('img')
img.setAttribute('src', input.url)
img.setAttribute('alt', input.index)
img.setAttribute('height', input.imgH)
img.setAttribute('width', input.imgW)
return img
}