From 97f7b7d55f25bf7a3712ca05e2a8202e2156244a Mon Sep 17 00:00:00 2001 From: Teodor Atroshenko Date: Sat, 18 May 2024 02:10:16 +0200 Subject: [PATCH] fix(QScrollArea): correctly compute snap position for thumb Resolves #17206 --- ui/src/components/scroll-area/QScrollArea.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/components/scroll-area/QScrollArea.js b/ui/src/components/scroll-area/QScrollArea.js index 0799d3d8612..48b54032e59 100644 --- a/ui/src/components/scroll-area/QScrollArea.js +++ b/ui/src/components/scroll-area/QScrollArea.js @@ -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