From cf163cc95482afaa3cdacdc6d2229d5477e07e42 Mon Sep 17 00:00:00 2001 From: Barugon <16503728+Barugon@users.noreply.github.com> Date: Tue, 5 Sep 2023 01:44:23 -0700 Subject: [PATCH] Add `scroll_area::State::velocity` (#3300) * Implement `has_momentum` * Add doc comment * Call it `has_velocity` * Implement `velocity` method --------- Co-authored-by: Emil Ernerfeldt --- crates/egui/src/containers/scroll_area.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 5f7a9a03..0c2cead7 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -54,6 +54,11 @@ impl State { pub fn store(self, ctx: &Context, id: Id) { ctx.data_mut(|d| d.insert_persisted(id, self)); } + + /// Get the current kinetic scrolling velocity. + pub fn velocity(&self) -> Vec2 { + self.vel + } } pub struct ScrollAreaOutput {