1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Smoother panel animation (#8199)

This commit is contained in:
Emil Ernerfeldt
2026-05-25 15:25:26 +02:00
committed by GitHub
parent f57291bac0
commit 5669725b1c

View File

@@ -778,10 +778,19 @@ impl Panel {
parent_ui.set_cursor_icon(self.cursor_icon(outer_size)); parent_ui.set_cursor_icon(self.cursor_icon(outer_size));
} }
if !resize_drag_in_progress { let is_animating = 0.0 < self.slide_fraction && self.slide_fraction < 1.0;
// Skipping during a drag if !resize_drag_in_progress && !is_animating || PanelState::load(parent_ui, id).is_none() {
// means the stored size reflects the panel's pre-drag size — so a // We skip stoing state during a drag, so that the
// drag-to-close followed by a drag-to-reopen restores the original size. // stored size reflects the panel's pre-drag size.
// This is so that drag-to-close followed by a drag-to-reopen restores the original size.
// Skipping when `!persist_state` keeps interpolated sizes (set by the
// collapse animation in `show_switched`) from polluting the panel's
// natural persisted size.
// Finally, we always store the state if it's not already stored,
// so we get a good estimate for the final size when first expanding a panel.
PanelState { PanelState {
outer_rect: shifted_outer_rect, outer_rect: shifted_outer_rect,
} }