Skip to content

Commit

Permalink
fix(QScrollArea): correctly compute snap position for thumb
Browse files Browse the repository at this point in the history
  • Loading branch information
thexeos committed May 18, 2024
1 parent 36146ba commit 97f7b7d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/src/components/scroll-area/QScrollArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ export default createComponent({
if (data.thumbHidden.value !== true) {
const offset = evt[ dirProps[ axis ].offset ]
if (offset < data.thumbStart.value || offset > data.thumbStart.value + data.thumbSize.value) {
const pos = offset - data.thumbSize.value / 2
setScroll(pos / container[ axis ].value * data.size.value, axis)
const targetThumbStart = offset - data.thumbSize.value / 2
const percentage = between(targetThumbStart / (props.container[ axis ].value - data.thumbSize.value), 0, 1)
setScroll(percentage * Math.max(0, data.size.value - props.container[ axis ].value), axis)
}

// activate thumb pan
Expand Down

0 comments on commit 97f7b7d

Please sign in to comment.