Fix mismatch between hit boxes and drawn items in legend plugin (#11352)

* Fix mismatch between hit boxes and drawn items in legend plugin

* fixes padding calculation
This commit is contained in:
stockiNail 2023-06-20 18:20:12 +02:00 committed by GitHub
parent 1c2dd6898e
commit 57bbd8229d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -428,7 +428,7 @@ export class Legend extends Element {
cursor.x += width + padding; cursor.x += width + padding;
} else if (typeof legendItem.text !== 'string') { } else if (typeof legendItem.text !== 'string') {
const fontLineHeight = labelFont.lineHeight; const fontLineHeight = labelFont.lineHeight;
cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight); cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight) + padding;
} else { } else {
cursor.y += lineHeight; cursor.y += lineHeight;
} }
@ -575,7 +575,7 @@ function calculateItemHeight(_itemHeight, legendItem, fontLineHeight) {
} }
function calculateLegendItemHeight(legendItem, fontLineHeight) { function calculateLegendItemHeight(legendItem, fontLineHeight) {
const labelHeight = legendItem.text ? legendItem.text.length + 0.5 : 0; const labelHeight = legendItem.text ? legendItem.text.length : 0;
return fontLineHeight * labelHeight; return fontLineHeight * labelHeight;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 17 KiB