Skip to main content

Keyframes

Struct Keyframes 

Source
pub struct Keyframes { /* private fields */ }
Expand description

The steps of an animation, written as @keyframes <name>.

Style::keyframes sets an element’s animation-name to it and carries the rule along, so the page or the patch that brings the element also brings the rule. Two Keyframes with the same name are one rule to the browser, and the later one in the stylesheet wins; nothing checks that each name is used once.

use hypersig_style::value::{AnimationIterationCount, Transform, deg, ms, raw};
use hypersig_style::{Keyframes, Sheet, Style};

let spin = Keyframes::new("spin")
    .at(0, Style::new().transform(raw("rotate(0deg)")))
    .at(100, Style::new().transform(raw("rotate(360deg)")));
let spinner = Style::new()
    .keyframes(&spin)
    .animation_duration(ms(800))
    .animation_iteration_count(AnimationIterationCount::Infinite);
let mut sheet = Sheet::new();
sheet.add(&spinner);
assert!(sheet.to_css().contains("@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}"));

Implementations§

Source§

impl Keyframes

Source

pub fn new(name: &'static str) -> Self

Keyframes named name, with no steps yet.

§Panics

Panics if name is empty, starts with a digit, or holds a character other than an ASCII letter, digit, -, or _, which an animation-name would need quoted.

Source

pub fn at(self, percent: u8, style: Style) -> Self

Adds the declarations of style at percent of the animation.

Only the unconditioned declarations of style are written, because a keyframe takes no selector or media query.

§Panics

Panics if percent is over 100.

Source

pub fn name(&self) -> &'static str

The name animation-name refers to.

Trait Implementations§

Source§

impl Clone for Keyframes

Source§

fn clone(&self) -> Keyframes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Keyframes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Keyframes

Source§

fn eq(&self, other: &Keyframes) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Keyframes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.