mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-18 20:19:30 -07:00
now creation of image element can be achieved by createImgElement function in utils.ts
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
import { overlayEnable } from './overlay'
|
import { overlayEnable } from './overlay'
|
||||||
import { posCache, FIFO, layersPosSet, center, type position } from './utils'
|
import {
|
||||||
|
posCache,
|
||||||
|
FIFO,
|
||||||
|
layersPosSet,
|
||||||
|
center,
|
||||||
|
type position,
|
||||||
|
createImgElement
|
||||||
|
} from './utils'
|
||||||
import { thresholdSensitivityArray, thresholdIndex } from './thresholdCtl'
|
import { thresholdSensitivityArray, thresholdIndex } from './thresholdCtl'
|
||||||
import { imgIndexSpanUpdate } from './indexDisp'
|
import { imgIndexSpanUpdate } from './indexDisp'
|
||||||
import { imagesArrayLen, imagesArray } from './dataFetch'
|
import { imagesArrayLen, imagesArray } from './dataFetch'
|
||||||
@@ -26,14 +33,9 @@ let last: position = { x: 0, y: 0 }
|
|||||||
|
|
||||||
// activate top image
|
// activate top image
|
||||||
const activate = (index: number, x: number, y: number): void => {
|
const activate = (index: number, x: number, y: number): void => {
|
||||||
const img = document.createElement('img')
|
|
||||||
img.setAttribute('src', imagesArray[index].url)
|
|
||||||
img.setAttribute('alt', imagesArray[index].index)
|
|
||||||
img.setAttribute('height', imagesArray[index].imgH)
|
|
||||||
img.setAttribute('width', imagesArray[index].imgW)
|
|
||||||
posCache(x, y, posArray)
|
posCache(x, y, posArray)
|
||||||
layersPosSet(posArray, layers)
|
layersPosSet(posArray, layers)
|
||||||
FIFO(img, layers)
|
FIFO(createImgElement(imagesArray[index]), layers)
|
||||||
// top
|
// top
|
||||||
layer5.addEventListener(
|
layer5.addEventListener(
|
||||||
'click',
|
'click',
|
||||||
|
|||||||
@@ -79,3 +79,12 @@ export const center = (e: HTMLDivElement): void => {
|
|||||||
e.style.top = 'calc((100% - 31px) / 2 + 31px)'
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user