Skip to content

Commit 4ea3eab

Browse files
6heogoffart
authored andcommitted
fix scrollbar jumping bug for qt style
1 parent 27621da commit 4ea3eab

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

internal/backends/qt/qt_widgets/scrollview.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl Item for NativeScrollView {
171171
if new_control == SC_ScrollBarSlider {
172172
data.pressed_x = pos as f32;
173173
data.pressed_val = -value as f32;
174+
data.pressed_max = max as f32;
174175
}
175176
data.active_controls = new_control;
176177
InputEventResult::GrabMouse
@@ -210,6 +211,17 @@ impl Item for NativeScrollView {
210211
MouseEvent::Moved { .. } => {
211212
if data.pressed != 0 && data.active_controls == SC_ScrollBarSlider {
212213
let max = max as f32;
214+
215+
// Update reference points when the size of the viewport changes to
216+
// avoid 'jumping' during scrolling.
217+
// This happens when the height estimate of a ListView changes after
218+
// new items are loaded.
219+
if data.pressed_max != max {
220+
data.pressed_x = pos as f32;
221+
data.pressed_val = -value as f32;
222+
data.pressed_max = max;
223+
}
224+
213225
let new_val = data.pressed_val
214226
+ ((pos as f32) - data.pressed_x) * (max + (page_size as f32))
215227
/ size as f32;

internal/backends/qt/qt_widgets/slider.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(super) struct NativeSliderData {
1717
pub pressed: u8,
1818
pub pressed_x: f32,
1919
pub pressed_val: f32,
20+
pub pressed_max: f32,
2021
}
2122

2223
type FloatArg = (f32,);

internal/core/items/flickable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl FlickableData {
442442

443443
// Update reference points when the size of the viewport changes to
444444
// avoid 'jumping' during scrolling.
445-
// This happens when height estimate of a ListView changes after
445+
// This happens when the height estimate of a ListView changes after
446446
// new items are loaded.
447447
if current_viewport_size != inner.pressed_viewport_size {
448448
inner.pressed_viewport_size = current_viewport_size;

0 commit comments

Comments
 (0)