aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Layout.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-09-22 12:56:44 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-09-22 12:56:45 +0800
commit5125cc7a08dbeb3d85d17cfaac844b4dc027e91d (patch)
tree1245e56df9d44064adf5ecf82673090180eb8f42 /src/Layout.mjs
parent6d930d449f78b952d11ba524e33fe39c52d6e2df (diff)
feat(layout): keep handle be active when on drag
Even if cursor is not hovering handle element
Diffstat (limited to 'src/Layout.mjs')
-rw-r--r--src/Layout.mjs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs
index c81225f..746dda2 100644
--- a/src/Layout.mjs
+++ b/src/Layout.mjs
@@ -78,7 +78,7 @@ export class Overlay extends Layout {
78 draggablePart.onmouseup = (e) => { 78 draggablePart.onmouseup = (e) => {
79 if (e.button === 1) { 79 if (e.button === 1) {
80 // Hide block with middle click 80 // Hide block with middle click
81 draggableBlock.setAttribute("data-hide", "true") 81 draggableBlock.setAttribute("data-state", "hide")
82 } 82 }
83 } 83 }
84 84
@@ -95,7 +95,7 @@ export class Overlay extends Layout {
95 95
96 // Close button 96 // Close button
97 draggableBlock.querySelector('#close').onclick = () => { 97 draggableBlock.querySelector('#close').onclick = () => {
98 draggableBlock.setAttribute("data-hide", "true") 98 draggableBlock.setAttribute("data-state", "hide")
99 } 99 }
100 // Plus/Minus font-size of content 100 // Plus/Minus font-size of content
101 draggableBlock.querySelector('#plus-font-size').onclick = () => { 101 draggableBlock.querySelector('#plus-font-size').onclick = () => {
@@ -106,12 +106,16 @@ export class Overlay extends Layout {
106 const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 106 const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16
107 block.style.fontSize = `${fontSize - 0.1}rem` 107 block.style.fontSize = `${fontSize - 0.1}rem`
108 } 108 }
109
110 // FIXME use pure CSS to hide utils
109 const utils = draggableBlock.querySelector('.utils') 111 const utils = draggableBlock.querySelector('.utils')
110 draggableInstance.onDragStart = () => { 112 draggableInstance.onDragStart = () => {
111 utils.style.opacity = 0 113 utils.style.opacity = 0
114 draggableBlock.setAttribute('data-state', 'on-drag')
112 } 115 }
113 draggableInstance.onDragEnd = () => { 116 draggableInstance.onDragEnd = () => {
114 utils.style = '' 117 utils.style = ''
118 draggableBlock.removeAttribute('data-state')
115 } 119 }
116 120
117 // Reposition draggable instance when resized 121 // Reposition draggable instance when resized