Skip to main content

Flipping

Trait Flipping 

Source
pub trait Flipping: IntoElement + Sized {
    // Provided methods
    fn flip(self, flip: &Flip, window: &mut Window, cx: &mut App) -> Flipped { ... }
    fn flip_size(
        self,
        flip: &Flip,
        window: &mut Window,
        cx: &mut App,
    ) -> Flipped { ... }
}
Expand description

Slides an element from where it was to where it is.

Provided Methods§

Source

fn flip(self, flip: &Flip, window: &mut Window, cx: &mut App) -> Flipped

Wraps the element so a change in its position is played back as a slide.

The wrapper contributes no box of its own and the offset is applied after layout, so this cannot move anything beside the element.

Under reduced motion the element is simply at its new place from the first frame.

Source

fn flip_size(self, flip: &Flip, window: &mut Window, cx: &mut App) -> Flipped

The same, and a change in the element’s size is played back too.

This costs what Flipping::flip does not. The element takes a layout node of its own, is measured twice a frame while it animates, and is genuinely the animated size rather than a scaled picture of the settled one — so its siblings move with it, and the size the semantic tree publishes is the size in flight. Position and size run independently, so an element that both moves and grows does both.

Under reduced motion the element is at its new size from the first frame.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§