Skip to content

Commit

Permalink
#972: ScrollArea::stick_to_bottom() has no effect if ScrollArea is no…
Browse files Browse the repository at this point in the history
…t initialized.
  • Loading branch information
singalen committed Dec 19, 2021
1 parent 08cc07b commit 398ae85
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,14 @@ impl Prepared {
state.offset = state.offset.min(available_offset);
state.offset = state.offset.max(Vec2::ZERO);

// Is scroll handle at end of content? If so enter sticky mode.
// Is scroll handle at end of content, or is there no scrollbar
// yet (not enough content), but sticking is requested? If so, enter sticky mode.
// Only has an effect if stick_to_end is enabled but we save in
// state anyway so that entering sticky mode at an arbitrary time
// has appropriate effect.
state.scroll_stuck_to_end = [
state.offset[0] == available_offset[0],
state.offset[1] == available_offset[1],
(state.offset[0] == available_offset[0]) || (self.stick_to_end[0] && available_offset[0] < 0.),
(state.offset[1] == available_offset[1]) || (self.stick_to_end[1] && available_offset[1] < 0.),
];

state.show_scroll = show_scroll_this_frame;
Expand Down

0 comments on commit 398ae85

Please sign in to comment.