From d05379902cbfe78a9e0b9e3a6d1888f0a9562863 Mon Sep 17 00:00:00 2001 From: Victor Sergienko Date: Sat, 25 Dec 2021 07:29:11 -0800 Subject: [PATCH] #972: ScrollArea::stick_to_bottom() has no effect if ScrollArea is not initialized. (#973) --- egui/src/containers/scroll_area.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index e6a70530..6bfc942a 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -733,13 +733,16 @@ 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;