From cadee8b623805e656f6544166996173d6570f17b Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 24 Sep 2024 12:51:20 +0800 Subject: feat: add timer for z-index change of draggable block --- src/Layout.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Layout.mjs') diff --git a/src/Layout.mjs b/src/Layout.mjs index 23588a1..51caefb 100644 --- a/src/Layout.mjs +++ b/src/Layout.mjs @@ -61,9 +61,15 @@ export class Overlay extends Layout { addDraggable = (element) => { // Make sure current element always on top const siblings = Array.from(element.parentElement?.querySelectorAll(':scope > *') ?? []) + let popTimer = null element.onmouseover = () => { - siblings.forEach(e => e.style.removeProperty('z-index')) - element.style.zIndex = '9000' + popTimer = setTimeout(() => { + siblings.forEach(e => e.style.removeProperty('z-index')) + element.style.zIndex = '9000' + }, 200) + } + element.onmouseout = () => { + clearTimeout(popTimer) } // Add draggable part -- cgit v1.2.3-70-g09d2