From 92a360cbc2511993158614aca176deb4682b54d6 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Wed, 19 Apr 2023 09:27:29 +0800 Subject: [PATCH] popup.rect get & set --- lib/ui/checkbox.js | 2 +- lib/ui/icon.js | 2 +- lib/ui/popup.html | 1 + lib/ui/popup.js | 64 ++++++++++++++++++++++++++++++++++++---------- lib/ui/tooltip.js | 2 +- 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/lib/ui/checkbox.js b/lib/ui/checkbox.js index b9625f7..1ddb19d 100644 --- a/lib/ui/checkbox.js +++ b/lib/ui/checkbox.js @@ -6,7 +6,7 @@ function fillCheckbox(container, type, label, charactor = 'check') { container.appendChild( createElement('layer', 'check-box-inner', createIcon(type, charactor)) ); - if (label instanceof HTMLElement) { + if (label instanceof Element) { container.appendChild(label); } else if (label?.length > 0) { container.appendChild( diff --git a/lib/ui/icon.js b/lib/ui/icon.js index 04a6920..4c085c2 100644 --- a/lib/ui/icon.js +++ b/lib/ui/icon.js @@ -10,7 +10,7 @@ function createUse(type, id) { } function changeIcon(svg, type, id) { - if (svg instanceof HTMLElement) { + if (svg instanceof SVGElement) { svg.replaceChildren(createUse(type, id)); } return svg; diff --git a/lib/ui/popup.html b/lib/ui/popup.html index 977ab2b..ccb0645 100644 --- a/lib/ui/popup.html +++ b/lib/ui/popup.html @@ -38,6 +38,7 @@ onResizeEnded: () => console.log('resize ended.', popup.rect) }); popup.show(); + window.popup = popup; });