From a2547a2c1275949dd0404f247a0eeeb3c2feb00b Mon Sep 17 00:00:00 2001 From: Spedon Date: Fri, 10 Mar 2023 16:03:48 +0800 Subject: [PATCH] add click to center function --- assets/js/theme.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assets/js/theme.js b/assets/js/theme.js index 915e50b..365c342 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -58,11 +58,22 @@ function init () { // let specified image show 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.top = `${y}px` image.style.zIndex = '' + globalIndex image.dataset.status = 'active' + image.classList.add('top') + image.addEventListener('click', () => { + image.style.left = '50%' + image.style.top = '50%' + }) last = { x, y } }