mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-18 20:19:30 -07:00
add click to center function
This commit is contained in:
@@ -58,11 +58,22 @@ function init () {
|
|||||||
|
|
||||||
// let specified image show
|
// let specified image show
|
||||||
const activate = (image, x, y) => {
|
const activate = (image, x, y) => {
|
||||||
|
for (const node of document.getElementsByClassName('top')) {
|
||||||
|
if (node.classList.contains('top')) {
|
||||||
|
node.classList.remove('top')
|
||||||
|
node.replaceWith(node.cloneNode(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
image.style.left = `${x}px`
|
image.style.left = `${x}px`
|
||||||
image.style.top = `${y}px`
|
image.style.top = `${y}px`
|
||||||
image.style.zIndex = '' + globalIndex
|
image.style.zIndex = '' + globalIndex
|
||||||
|
|
||||||
image.dataset.status = 'active'
|
image.dataset.status = 'active'
|
||||||
|
image.classList.add('top')
|
||||||
|
image.addEventListener('click', () => {
|
||||||
|
image.style.left = '50%'
|
||||||
|
image.style.top = '50%'
|
||||||
|
})
|
||||||
|
|
||||||
last = { x, y }
|
last = { x, y }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user