aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Layout.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-19 20:45:38 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-19 20:56:35 +0800
commit17aecaacfffba3fe0f27809ab48f43d7dbf1b7c4 (patch)
treeda9fa47e33367000c9e539ca9fd35e4f33fbd4dc /src/Layout.mjs
parent13b796b5b3207c0d0c9a00e7be9f916d897cda28 (diff)
fix(CSS): display of utils in draggable-block
* remove trivial implementation for case about font resizing, to make hover works * add rules for dragging
Diffstat (limited to 'src/Layout.mjs')
-rw-r--r--src/Layout.mjs22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs
index 04acc3d..8c6a8ea 100644
--- a/src/Layout.mjs
+++ b/src/Layout.mjs
@@ -125,15 +125,12 @@ const addDraggable = (element, { snap, left, top } = {}) => {
125 }) 125 })
126 126
127 // FIXME use pure CSS to hide utils 127 // FIXME use pure CSS to hide utils
128 const utils = element.querySelector('.utils')
129 draggable.onDragStart = () => { 128 draggable.onDragStart = () => {
130 if (utils) utils.style.display = 'none' 129 element.classList.add('dragging')
131 element.classList.add('drag')
132 } 130 }
133 131
134 draggable.onDragEnd = () => { 132 draggable.onDragEnd = () => {
135 if (utils) utils.style = '' 133 element.classList.remove('dragging')
136 element.classList.remove('drag')
137 element.style.zIndex = '9000' 134 element.style.zIndex = '9000'
138 } 135 }
139 136
@@ -244,24 +241,9 @@ export class Overlay extends Layout {
244 }, 241 },
245 })) 242 }))
246 243
247 // Trivial case:
248 // This hack make sure utils remains at the same place even when wrapper resized
249 // Prevent DOMRect changes when user clicking plus/minus button many times
250 const utils = wrapper.querySelector('.utils')
251 utils.onmouseover = () => {
252 const { left, top } = utils.getBoundingClientRect()
253 utils.style.cssText = `visibility: visible; z-index: 9000; position: fixed; transition: unset; left: ${left}px; top: ${top}px;`
254 document.body.appendChild(utils)
255 }
256 utils.onmouseout = () => {
257 wrapper.appendChild(utils)
258 utils.style.cssText = ''
259 }
260
261 // Close button 244 // Close button
262 wrapper.querySelector('#close').onclick = () => { 245 wrapper.querySelector('#close').onclick = () => {
263 block.classList.remove('focus') 246 block.classList.remove('focus')
264 utils.style.cssText = ''
265 } 247 }
266 // Plus/Minus font-size of content 248 // Plus/Minus font-size of content
267 wrapper.querySelector('#plus-font-size').onclick = () => { 249 wrapper.querySelector('#plus-font-size').onclick = () => {