From dfcead330a8cd5ec2e01ce2646d1ff2dcb35b423 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 30 May 2024 18:57:37 +0900 Subject: [PATCH] Update scroll_area.rs --- crates/egui/src/containers/scroll_area.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 229870db9d4..2bd1c811884 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -783,14 +783,7 @@ impl Prepared { let content_size = content_ui.min_size(); - let scroll_delta = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta)); - for d in 0..2 { - // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. - let mut delta = -scroll_delta[d]; - // We always take both scroll targets regardless of which scroll axes are enabled. This // is to avoid them leaking to other scroll areas. let scroll_target = content_ui @@ -798,6 +791,13 @@ impl Prepared { .frame_state_mut(|state| state.scroll_target[d].take()); if scroll_enabled[d] { + let scroll_delta = content_ui + .ctx() + .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta[d])); + + // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. + let mut delta = -scroll_delta; + delta += if let Some((target_range, align)) = scroll_target { let min = content_ui.min_rect().min[d]; let clip_rect = content_ui.clip_rect();