From b9e531c9eabc511f386a81214f1ab16370b7942b Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 18 Jul 2023 13:49:41 +0200 Subject: [PATCH] Perfect lineout of line heading height matching --- amd/src/studyplan-editor-components.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/amd/src/studyplan-editor-components.js b/amd/src/studyplan-editor-components.js index 7437e1c..7dfbe0c 100644 --- a/amd/src/studyplan-editor-components.js +++ b/amd/src/studyplan-editor-components.js @@ -1531,12 +1531,13 @@ export default { // determine the height of all the lines and add them up. let heightSum = 0; items.forEach((el) => { - const height = el.offsetHeight; + // getBoundingClientRect() Gets the actual fractional height instead of rounded to integer pixels + const r = el.getBoundingClientRect(); + const height = r.height; heightSum += height; }); - const heightStyle=`${heightSum-0.5}px`; - debug.info(`Received line height change line ${lineid} to ${heightStyle}`); + const heightStyle=`${heightSum}px`; this.$refs.mainEl.style.height = heightStyle; } } @@ -1671,12 +1672,9 @@ export default { mounted() { const self=this; if(self.type == "gradable" && self.slotindex == 1){ - debug.info(`Creating height listener for line ${self.line.id} type ${self.type} slot ${self.slotindex}`, - "element",self.$refs.sizeElement); self.resizeListener = new ResizeObserver(() => { if(self.$refs.sizeElement){ - const height = self.$refs.sizeElement.clientHeight; - debug.info(`Sending height change event line ${self.line.id} height ${height}`); + const height = self.$refs.sizeElement.getBoundingClientRect().height; ItemEventBus.$emit('lineHeightChange', self.line.id, self.layer, height); } }).observe(self.$refs.sizeElement);