From d928c0def732e5f97dd9fcd9ea1d53e6fe8bb4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=BC=E5=87=AF?= Date: Thu, 28 Mar 2024 16:12:53 +0800 Subject: [PATCH 1/2] fix The pop-up content is too long, causing top to be negative. --- src/js/core/tools/Popup.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/core/tools/Popup.js b/src/js/core/tools/Popup.js index 644838c9f..dd89d0e2b 100644 --- a/src/js/core/tools/Popup.js +++ b/src/js/core/tools/Popup.js @@ -196,7 +196,8 @@ export default class Popup extends CoreFeature{ } //move menu to start on bottom edge if it is too close to the edge of the screen - if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) { + let offsetHeight = Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0); + if((y + this.element.offsetHeight) > offsetHeight) { if(parentEl){ switch(position){ case "bottom": @@ -208,7 +209,7 @@ export default class Popup extends CoreFeature{ } }else{ - this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px"; + this.element.style.height = offsetHeight + "px"; } } } @@ -302,4 +303,4 @@ export default class Popup extends CoreFeature{ return this.childPopup; } -} \ No newline at end of file +} From 9de102061179304e5b56c1611ebb9fb682941e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=BC=E5=87=AF?= <> Date: Thu, 6 Jun 2024 11:22:25 +0800 Subject: [PATCH 2/2] feat ResizeTable adds anti-shake redraw --- src/js/modules/ResizeTable/ResizeTable.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/js/modules/ResizeTable/ResizeTable.js b/src/js/modules/ResizeTable/ResizeTable.js index c071cdae6..ed413c2f3 100644 --- a/src/js/modules/ResizeTable/ResizeTable.js +++ b/src/js/modules/ResizeTable/ResizeTable.js @@ -23,7 +23,7 @@ export default class ResizeTable extends Module{ this.initialized = false; this.initialRedraw = false; - + this.debouncedRedrawTable = this.debounce(this.redrawTable, 100); this.registerTableOption("autoResize", true); //auto resize table } @@ -60,8 +60,7 @@ export default class ResizeTable extends Module{ this.containerHeight = table.element.parentNode.clientHeight; this.containerWidth = table.element.parentNode.clientWidth; } - - this.redrawTable(); + this.debouncedRedrawTable(); } } }); @@ -84,8 +83,8 @@ export default class ResizeTable extends Module{ this.tableHeight = table.element.clientHeight; this.tableWidth = table.element.clientWidth; } - - this.redrawTable(); + + this.debouncedRedrawTable(); } }); @@ -155,4 +154,14 @@ export default class ResizeTable extends Module{ this.containerObserver.unobserve(this.table.element.parentNode); } } -} \ No newline at end of file + + debounce(func, delay) { + let timerId; + return function(...args) { + clearTimeout(timerId); + timerId = setTimeout(() => { + func.apply(this); + }, delay); + }; + } +}