Skip to main content

Module enter

Module enter 

Source
Expand description

Entrance transitions: where a node’s animatable slots start on the first frame it is seen.

Without one, a node’s first sight snaps into place. NodeSpec::enter takes an Enter naming where the slots start instead (dx/dy for the position, plus width, height, bg, radius and opacity), and they ease from there to what the view declares over the node’s transition. NodeSpec::exit takes the same type read the other way: where the slots end after the view stops declaring the node.

use kui_core::{Core, Enter, NodeSpec, Size};

let mut core = Core::new();
let mut ui = core.frame(Size::new(400.0, 300.0), 1.0);
// A toast that rises 24 px and fades in over 200 ms when it first appears,
// and does the reverse when the view stops declaring it.
ui.leaf_keyed(
    "toast",
    NodeSpec::row()
        .size(200.0, 40.0)
        .transition(200.0)
        .enter(Enter::from(0.0, 24.0).opacity(0.0))
        .exit(Enter::from(0.0, 24.0).opacity(0.0)),
);
ui.finish();

dx/dy move the node’s position in place, subtree and all; a node with enter but no slide eases only its entrance, and a later layout move still snaps. Slots a keyframes stop names are sampled, not tweened, so enter leaves them alone. A node that leaves and comes back enters again.

Structs§

Enter
Where a node’s slots start on first sight. Every field is optional: a slot enter doesn’t name simply snaps as it always did. Derefs to its Slots, so enter.bg reads the slot.

Functions§

parse
An entrance from plain data: a map with any of dx, dy, width, height, bg, radius, opacity, in the forms the props themselves take (the same shapes a keyframe stop accepts). Every binding funnels enter through here, so the shape is the same in JSX, Lua and C.
parse_with
parse with a token lookup, as keyframes::parse_with: a $name in width, height, bg or radius resolves, and a miss leaves the slot unnamed and is remembered on the refs.