aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-09-11 01:08:44 +0200
committerdec05eba <dec05eba@protonmail.com>2024-09-11 01:08:44 +0200
commit8746e8e43c9c47454ca7a115969cd07746fd832e (patch)
tree18f040ca911e9df372359e4ebdd2a95f22fac43a
parentdd906c6a9dde666af0b10cc016039f312733201f (diff)
Hard limit on scroll without animation when reaching top/bottom
-rw-r--r--src/gui/ScrollablePage.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp
index a91367c..62f2a3e 100644
--- a/src/gui/ScrollablePage.cpp
+++ b/src/gui/ScrollablePage.cpp
@@ -74,7 +74,6 @@ namespace gsr {
const mgl::vec2f scrollbar_pos = position + offset + mgl::vec2f(size.x - scrollbar_width, 0.0f);
offset = position + offset;
- const mgl::vec2f page_scroll_start = offset;
mgl_scissor prev_scissor;
mgl_window_get_scissor(window.internal_window(), &prev_scissor);
@@ -143,11 +142,13 @@ namespace gsr {
}
// Top and bottom limit
- const double child_draw_overflow = (page_scroll_start.y + size.y) - child_bottom;
+ const double scroll_bottom_limit = child_height - size.y;
if(scroll_y > 0.001 || child_height < size.y) {
+ scroll_y = 0;
scroll_target_y = 0;
- } else if(child_draw_overflow > 0.001) {
- scroll_target_y = scroll_y + child_draw_overflow;
+ } else if(scroll_y < -scroll_bottom_limit) {
+ scroll_y = -scroll_bottom_limit;
+ scroll_target_y = -scroll_bottom_limit;
}
mgl_window_set_scissor(window.internal_window(), &prev_scissor);
@@ -179,7 +180,6 @@ namespace gsr {
}
if(moving_scrollbar_with_cursor) {
- const double scroll_bottom_limit = child_height - size.y;
const mgl::vec2f scrollbar_move_diff = window.get_mouse_position().to_vec2f() - scrollbar_move_cursor_start_pos;
const double scroll_amount = scrollbar_move_diff.y / scrollbar_empty_space;
scroll_y = scrollbar_move_cursor_scroll_y_start - scroll_amount * (child_height - size.y);