Perfect lineout of line heading height matching

This commit is contained in:
PMKuipers 2023-07-18 13:49:41 +02:00
parent fa1e3daa6f
commit b9e531c9ea

View file

@ -1531,12 +1531,13 @@ export default {
// determine the height of all the lines and add them up. // determine the height of all the lines and add them up.
let heightSum = 0; let heightSum = 0;
items.forEach((el) => { 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; heightSum += height;
}); });
const heightStyle=`${heightSum-0.5}px`; const heightStyle=`${heightSum}px`;
debug.info(`Received line height change line ${lineid} to ${heightStyle}`);
this.$refs.mainEl.style.height = heightStyle; this.$refs.mainEl.style.height = heightStyle;
} }
} }
@ -1671,12 +1672,9 @@ export default {
mounted() { mounted() {
const self=this; const self=this;
if(self.type == "gradable" && self.slotindex == 1){ 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(() => { self.resizeListener = new ResizeObserver(() => {
if(self.$refs.sizeElement){ if(self.$refs.sizeElement){
const height = self.$refs.sizeElement.clientHeight; const height = self.$refs.sizeElement.getBoundingClientRect().height;
debug.info(`Sending height change event line ${self.line.id} height ${height}`);
ItemEventBus.$emit('lineHeightChange', self.line.id, self.layer, height); ItemEventBus.$emit('lineHeightChange', self.line.id, self.layer, height);
} }
}).observe(self.$refs.sizeElement); }).observe(self.$refs.sizeElement);