diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-22 12:17:04 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-22 12:17:04 +0800 |
commit | 6d930d449f78b952d11ba524e33fe39c52d6e2df (patch) | |
tree | f185b5ffec895459c4675a6589961e5a669b13cb /src/Layout.mjs | |
parent | 698262eb4f618ec6f6ae5b3389b935d7b34f1701 (diff) |
feat: add close button for draggable block
Diffstat (limited to 'src/Layout.mjs')
-rw-r--r-- | src/Layout.mjs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs index 5673722..c81225f 100644 --- a/src/Layout.mjs +++ b/src/Layout.mjs | |||
@@ -66,6 +66,7 @@ export class Overlay extends Layout { | |||
66 | <div class="handle">\u2630</div> | 66 | <div class="handle">\u2630</div> |
67 | </div> | 67 | </div> |
68 | <div class="utils"> | 68 | <div class="utils"> |
69 | <div id="close">\u274C</div> | ||
69 | <div id="plus-font-size" ">\u2795</div> | 70 | <div id="plus-font-size" ">\u2795</div> |
70 | <div id="minus-font-size">\u2796</div> | 71 | <div id="minus-font-size">\u2796</div> |
71 | </div> | 72 | </div> |
@@ -92,24 +93,25 @@ export class Overlay extends Layout { | |||
92 | snap: { x: { step: 20 }, y: { step: 20 } }, | 93 | snap: { x: { step: 20 }, y: { step: 20 } }, |
93 | }) | 94 | }) |
94 | 95 | ||
96 | // Close button | ||
97 | draggableBlock.querySelector('#close').onclick = () => { | ||
98 | draggableBlock.setAttribute("data-hide", "true") | ||
99 | } | ||
95 | // Plus/Minus font-size of content | 100 | // Plus/Minus font-size of content |
96 | const plusButton = draggableBlock.querySelector('#plus-font-size') | 101 | draggableBlock.querySelector('#plus-font-size').onclick = () => { |
97 | plusButton.onclick = () => { | ||
98 | const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 | 102 | const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 |
99 | block.style.fontSize = `${fontSize + 0.1}rem` | 103 | block.style.fontSize = `${fontSize + 0.1}rem` |
100 | } | 104 | } |
101 | const minusButton = draggableBlock.querySelector('#minus-font-size') | 105 | draggableBlock.querySelector('#minus-font-size').onclick = () => { |
102 | minusButton.onclick = () => { | ||
103 | const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 | 106 | const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 |
104 | block.style.fontSize = `${fontSize - 0.1}rem` | 107 | block.style.fontSize = `${fontSize - 0.1}rem` |
105 | } | 108 | } |
109 | const utils = draggableBlock.querySelector('.utils') | ||
106 | draggableInstance.onDragStart = () => { | 110 | draggableInstance.onDragStart = () => { |
107 | plusButton.style.opacity = '0' | 111 | utils.style.opacity = 0 |
108 | minusButton.style.opacity = '0' | ||
109 | } | 112 | } |
110 | draggableInstance.onDragEnd = () => { | 113 | draggableInstance.onDragEnd = () => { |
111 | plusButton.style = '' | 114 | utils.style = '' |
112 | minusButton.style = '' | ||
113 | } | 115 | } |
114 | 116 | ||
115 | // Reposition draggable instance when resized | 117 | // Reposition draggable instance when resized |