From a0367ba51dcbe7add00a8be5f20445b1ad182ea4 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Wed, 25 Dec 2024 00:16:51 -0500 Subject: [PATCH] fix: do not enlarge gap of last row --- page/scroll.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/page/scroll.ts b/page/scroll.ts index b3b0ac7..d67795d 100644 --- a/page/scroll.ts +++ b/page/scroll.ts @@ -141,9 +141,12 @@ export function recalculateScroll(scrollStart: boolean) { if (scrollEnd && rowItemCount[rowItemCount.length - 1] < MAX_COLUMN) { const dividers = hoverables.querySelectorAll('.fcitx-divider') const skipped = itemCountInFirstNRows(rowItemCount.length - 1) - const { width } = dividers[skipped - 1].getBoundingClientRect() // Don't use clientWidth as it rounds to integer. - for (let i = skipped; i < skipped + rowItemCount[rowItemCount.length - 1] - 1; ++i) { - dividers[i].setAttribute('style', `flex-grow: 0; flex-basis: ${width}px`) + const { width: gapOfPreviousRow } = dividers[skipped - 1].getBoundingClientRect() // Don't use clientWidth as it rounds to integer. + const { width: gapOfLastRow } = dividers[skipped].getBoundingClientRect() + if (gapOfLastRow > gapOfPreviousRow) { + for (let i = skipped; i < skipped + rowItemCount[rowItemCount.length - 1] - 1; ++i) { + dividers[i].setAttribute('style', `flex-grow: 0; flex-basis: ${gapOfPreviousRow}px`) + } } } }