Skip to content

Commit

Permalink
fix: do not enlarge gap of last row (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Dec 25, 2024
1 parent 5f76ddf commit d63bafd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions page/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
}
}
}
Expand Down

0 comments on commit d63bafd

Please sign in to comment.