Skip to content

ui::KeyFrameAnimation

Header: winui/ui/Animation.hpp.

A key frame animation of one property. The frames play from the property's current value. duration 0 is the last key time.

Example:

auto element = std::make_unique<ui::RectangleControl>();
element->start_animation(ui::AnimatedProperty::ScaleX,
                         ui::KeyFrameAnimation{.key_frames   = {ui::KeyFrame::linear(150ms, 1.2f),
                                                                ui::KeyFrame::linear(300ms, 1.0f)},
                                               .repeat_count = 2.0});

Field Type Default
key_frames std::vector<KeyFrame> The frames, sorted by time; the first segment starts at the property's current value.
duration Duration Iteration length; 0 uses the last key time.
repeat_count double 1.0 Iterations to run; infinity repeats forever.
fill FillBehavior FillBehavior::HoldEnd What the property shows once the animation finishes.
on_completed Callback<void()> Fires once when the animation finishes.