diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-24 12:51:20 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-24 12:51:20 +0800 |
commit | cadee8b623805e656f6544166996173d6570f17b (patch) | |
tree | 9148e4adb2425a8d0b1dd8ac39134c22d25d622f /src/Layout.mjs | |
parent | 9c3cbff5f1026697df0b209d6add736e7d4d346a (diff) |
feat: add timer for z-index change of draggable block
Diffstat (limited to 'src/Layout.mjs')
-rw-r--r-- | src/Layout.mjs | 10 |
1 files changed, 8 insertions, 2 deletions
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 { | |||
61 | addDraggable = (element) => { | 61 | addDraggable = (element) => { |
62 | // Make sure current element always on top | 62 | // Make sure current element always on top |
63 | const siblings = Array.from(element.parentElement?.querySelectorAll(':scope > *') ?? []) | 63 | const siblings = Array.from(element.parentElement?.querySelectorAll(':scope > *') ?? []) |
64 | let popTimer = null | ||
64 | element.onmouseover = () => { | 65 | element.onmouseover = () => { |
65 | siblings.forEach(e => e.style.removeProperty('z-index')) | 66 | popTimer = setTimeout(() => { |
66 | element.style.zIndex = '9000' | 67 | siblings.forEach(e => e.style.removeProperty('z-index')) |
68 | element.style.zIndex = '9000' | ||
69 | }, 200) | ||
70 | } | ||
71 | element.onmouseout = () => { | ||
72 | clearTimeout(popTimer) | ||
67 | } | 73 | } |
68 | 74 | ||
69 | // Add draggable part | 75 | // Add draggable part |