From 6d930d449f78b952d11ba524e33fe39c52d6e2df Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 22 Sep 2024 12:17:04 +0800 Subject: feat: add close button for draggable block --- src/Layout.mjs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Layout.mjs') 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 {
\u2630
+
\u274C
\u2795
\u2796
@@ -92,24 +93,25 @@ export class Overlay extends Layout { snap: { x: { step: 20 }, y: { step: 20 } }, }) + // Close button + draggableBlock.querySelector('#close').onclick = () => { + draggableBlock.setAttribute("data-hide", "true") + } // Plus/Minus font-size of content - const plusButton = draggableBlock.querySelector('#plus-font-size') - plusButton.onclick = () => { + draggableBlock.querySelector('#plus-font-size').onclick = () => { const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 block.style.fontSize = `${fontSize + 0.1}rem` } - const minusButton = draggableBlock.querySelector('#minus-font-size') - minusButton.onclick = () => { + draggableBlock.querySelector('#minus-font-size').onclick = () => { const fontSize = parseFloat(getComputedStyle(block).fontSize) / 16 block.style.fontSize = `${fontSize - 0.1}rem` } + const utils = draggableBlock.querySelector('.utils') draggableInstance.onDragStart = () => { - plusButton.style.opacity = '0' - minusButton.style.opacity = '0' + utils.style.opacity = 0 } draggableInstance.onDragEnd = () => { - plusButton.style = '' - minusButton.style = '' + utils.style = '' } // Reposition draggable instance when resized -- cgit v1.2.3-70-g09d2