Skip to content

Element Transitions

Header: winui/ui/Animation.hpp.

struct AddRemoveTransition

An added item grows from 90 % and fades in after the items it displaces have moved. A deleted one shrinks to 90 % and fades out, and the rest close the gap.

struct ContentTransition

New content slides in from the offset over 500 ms and fades in over 170 ms after 50 ms. Outgoing content fades out in 50 ms.

Field Type Default
offset_x float 0.0f Start x offset of incoming content, DIPs.
offset_y float 28.0f Start y offset of incoming content, DIPs.

struct EntranceTransition

An element entering the tree slides in from the given offset while it fades in, over 667 ms along (0.1,0.9)-(0.2,1). With staggering on, the elements that enter together start 35 ms apart.

Example:

window.set_content(ui::VerticalStack{
    .spacing              = 8,
    .children_transitions = {ui::EntranceTransition{.stagger = true}},
    .content              = {ui::Text{.text = "First"}, ui::Text{.text = "Second"}},
});

Field Type Default
offset_x float 0.0f Start x offset from the final position, DIPs.
offset_y float 28.0f Start y offset from the final position, DIPs.
stagger bool false Start elements entering together 35 ms apart.

struct NavigationTransition

An entry of a navigation frame's content transitions (set_content_transitions()). It animates navigation with the PageTransition passed to navigate(), or with this default when none was passed.

Example:

auto frame = std::make_unique<ui::NavigationFrameControl>();
frame->set_content_transitions({ui::NavigationTransition{
    .default_transition = ui::ZoomPageTransition{}}});
frame->navigate([] { return std::make_unique<ui::TextControl>("Details"); }); // zooms in

Field Type Default
default_transition std::optional<PageTransition> Used when navigate() is given no transition. Unset uses RisePageTransition.

struct PopupTransition

An opening popup slides in from the offset and fades in. A closing one fades out in 83 ms.

Example:

auto popup = std::make_unique<ui::PopupControl>();
popup->set_child_transitions({ui::PopupTransition{.offset_y = 20.0f}});

Field Type Default
offset_x float 0.0f Start x offset of the opening popup, DIPs.
offset_y float 40.0f Start y offset of the opening popup, DIPs.

struct RepositionTransition

An element that layout moves glides from where it was, over 367 ms. Staggering, on by default, starts the elements moved together 33 ms apart.

Example:

auto item = std::make_unique<ui::BorderControl>();
item->set_transitions({ui::RepositionTransition{.stagger = false}});

Field Type Default
stagger bool true Delay elements moved together 33 ms apart.

Tests

  • tests/test_animation.cpp