Skip to content

Commit

Permalink
Add public static function ScrollArea::is_scrolling()
Browse files Browse the repository at this point in the history
  • Loading branch information
bu5hm4nn committed Feb 15, 2024
1 parent 1187dd8 commit a142eed
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ pub struct ScrollArea {
stick_to_end: Vec2b,
}

impl ScrollArea {
pub fn is_scrolling(ui: &Ui, id_source: Id) -> bool {
let id = ui.make_persistent_id(id_source);
let scroll_target = ui.ctx().frame_state(|state| {
state.scroll_target[0].is_some() || state.scroll_target[1].is_some()
});
if let Some(state) = State::load(ui.ctx(), id) {
state.vel != Vec2::ZERO || scroll_target
} else {
false
}
}
}

impl ScrollArea {
/// Create a horizontal scroll area.
#[inline]
Expand Down

0 comments on commit a142eed

Please sign in to comment.