Skip to content

Commit

Permalink
Fix scroll sticking when scrollbars are not visible
Browse files Browse the repository at this point in the history
egui used to completely skip the stick calculation when the
scrollbars were not visible, which is incorrect.
  • Loading branch information
LoganDark committed Oct 3, 2023
1 parent 2338a85 commit bbcd93b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ impl Prepared {
}

for d in 0..2 {
// maybe force increase in offset to keep scroll stuck to end position
if stick_to_end[d] && state.scroll_stuck_to_end[d] {
state.offset[d] = content_size[d] - inner_rect.size()[d];
}

let animation_t = current_bar_use[1 - d] / max_scroll_bar_width;

if animation_t == 0.0 {
Expand Down Expand Up @@ -777,11 +782,6 @@ impl Prepared {
)
};

// maybe force increase in offset to keep scroll stuck to end position
if stick_to_end[d] && state.scroll_stuck_to_end[d] {
state.offset[d] = content_size[d] - inner_rect.size()[d];
}

let from_content =
|content| remap_clamp(content, 0.0..=content_size[d], min_main..=max_main);

Expand Down

0 comments on commit bbcd93b

Please sign in to comment.