Skip to content

Commit 145f8e2

Browse files
committedJul 22, 2024·
Add public static function ScrollArea::is_scrolling()
1 parent abab068 commit 145f8e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎crates/egui/src/containers/scroll_area.rs

+14
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ pub struct ScrollArea {
185185
animated: bool,
186186
}
187187

188+
impl ScrollArea {
189+
pub fn is_scrolling(ui: &Ui, id_source: Id) -> bool {
190+
let id = ui.make_persistent_id(id_source);
191+
let scroll_target = ui.ctx().frame_state(|state| {
192+
state.scroll_target[0].is_some() || state.scroll_target[1].is_some()
193+
});
194+
if let Some(state) = State::load(ui.ctx(), id) {
195+
state.vel != Vec2::ZERO || scroll_target
196+
} else {
197+
false
198+
}
199+
}
200+
}
201+
188202
impl ScrollArea {
189203
/// Create a horizontal scroll area.
190204
#[inline]

0 commit comments

Comments
 (0)
Please sign in to comment.