#animation #egui #transition #ui

egui_transition_animation

Easy animated transitions between multiple pages in egui

3 releases

0.1.3 Feb 6, 2025
0.1.2 Feb 1, 2025
0.1.1 Dec 20, 2024
0.1.0 Dec 20, 2024

#290 in GUI

Download history 187/week @ 2024-12-17 4/week @ 2024-12-24 1/week @ 2024-12-31 2/week @ 2025-01-07 109/week @ 2025-01-28 161/week @ 2025-02-04 12/week @ 2025-02-11

282 downloads per month

GPL-3.0-or-later

51KB
218 lines

Egui transition animation

This crate allows you to have animated transitions between multiple "pages" in egui.

crates.io | docs.rs | lib.rs | GitHub

egui_transition.webm

Quickstart

fn main() -> eframe::Result {
    use eframe::egui;
    use egui_transition_animation::prelude::*;

    #[derive(PartialEq, PartialOrd, Clone, Eq)]
    enum Page {
        Page1,
        Page2,
        Page3,
    }

    let mut page = Page::Page1;

    eframe::run_simple_native(
        "Egui transition animation example",
        Default::default(),
        move |ctx, _frame| {
            ctx.style_mut(|style| style.animation_time = 0.2);
            egui::CentralPanel::default().show(ctx, |ui| {
                ui.horizontal(|ui| {
                    ui.selectable_value(&mut page, Page::Page1, "Page 1");
                    ui.selectable_value(&mut page, Page::Page2, "Page 2");
                    ui.selectable_value(&mut page, Page::Page3, "Page 3");
                });

                animated_pager(
                    ui,
                    page.clone(),
                    &TransitionStyle::horizontal(ui),
                    egui::Id::new("pager"),
                    |ui, page| match page {
                        Page::Page1 => ui.label("Hello from page 1"),
                        Page::Page2 => ui.heading("Hello from page 2"),
                        Page::Page3 => ui.monospace("Hello from page 3"),
                    },
                )
            });
        },
    )
}

Contributing

Contributions are very welcome. Please don't forget to make PRs against the development branch, not the release branch.

Dependencies

~4.5–9MB
~89K SLoC