Skip to main content

RafDriver

Struct RafDriver 

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

requestAnimationFrame timestamp driver for JavaScript-owned animations.

Implementations§

Source§

impl RafDriver

Source

pub fn new() -> Self

Create an empty rAF driver.

Source

pub fn add_tween(&mut self, tween: &Tween) -> u32

Register a scalar tween and return its id.

Source

pub fn add_tween_2d(&mut self, tween: &Tween2D) -> u32

Register a 2D tween.

Source

pub fn add_tween_3d(&mut self, tween: &Tween3D) -> u32

Register a 3D tween.

Source

pub fn add_tween_4d(&mut self, tween: &Tween4D) -> u32

Register a 4D tween.

Source

pub fn add_spring(&mut self, spring: &Spring) -> u32

Register a scalar spring.

Source

pub fn add_spring_2d(&mut self, spring: &Spring2D) -> u32

Register a 2D spring.

Source

pub fn add_spring_3d(&mut self, spring: &Spring3D) -> u32

Register a 3D spring.

Source

pub fn add_spring_4d(&mut self, spring: &Spring4D) -> u32

Register a 4D spring.

Source

pub fn add_keyframes(&mut self, track: &KeyframeTrack) -> u32

Register a scalar keyframe track.

Source

pub fn add_keyframes_2d(&mut self, track: &KeyframeTrack2D) -> u32

Register a 2D keyframe track.

Source

pub fn add_keyframes_3d(&mut self, track: &KeyframeTrack3D) -> u32

Register a 3D keyframe track.

Source

pub fn add_keyframes_4d(&mut self, track: &KeyframeTrack4D) -> u32

Register a 4D keyframe track.

Source

pub fn add_timeline(&mut self, timeline: &Timeline) -> u32

Register a timeline.

Source

pub fn add_motion_path(&mut self, motion: &MotionPath) -> u32

Register a motion path.

Source

pub fn add_inertia(&mut self, inertia: &Inertia) -> u32

Register scalar inertia.

Source

pub fn add_inertia_2d(&mut self, inertia: &Inertia2D) -> u32

Register 2D inertia.

Source

pub fn tick(&mut self, timestamp_ms: f64) -> f32

Tick from a browser rAF timestamp in milliseconds.

Returns the seconds delta applied to animations.

Source

pub fn tick_dt(&mut self, dt: f32)

Tick by an explicit seconds delta.

Source

pub fn pause(&mut self)

Pause ticking.

Source

pub fn resume(&mut self)

Resume ticking.

Source

pub fn is_paused(&self) -> bool

Whether ticking is paused.

Source

pub fn reset_timestamp(&mut self)

Reset stored timestamp.

Source

pub fn set_time_scale(&mut self, scale: f32)

Set time scale.

Source

pub fn set_max_dt(&mut self, max_dt: f32)

Set maximum accepted frame delta.

Source

pub fn cancel(&mut self, id: u32)

Cancel an animation by id.

Source

pub fn cancel_all(&mut self)

Cancel all animations.

Source

pub fn active_count(&self) -> usize

Number of active animations.

Source

pub fn is_active(&self, id: u32) -> bool

Whether an animation id is active.

Trait Implementations§

Source§

impl Debug for RafDriver

Source§

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

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

impl Default for RafDriver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<RafDriver> for JsValue

Source§

fn from(value: RafDriver) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for RafDriver

Source§

type Abi = WasmPtr<WasmRefCell<RafDriver>>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for RafDriver

Source§

type Abi = WasmPtr<WasmRefCell<RafDriver>>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for RafDriver

Source§

type Abi = WasmPtr<WasmRefCell<RafDriver>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<RafDriver>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for RafDriver

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for RafDriver

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for RafDriver

Source§

type Abi = WasmPtr<WasmRefCell<RafDriver>>

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<RafDriver>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for RafDriver

Source§

type Abi = WasmPtr<WasmRefCell<RafDriver>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<RafDriver>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for RafDriver

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for RafDriver

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[RafDriver]>

Source§

impl VectorIntoWasmAbi for RafDriver

Source§

impl WasmDescribe for RafDriver

Source§

impl WasmDescribeVector for RafDriver

Source§

impl SupportsConstructor for RafDriver

Source§

impl SupportsInstanceProperty for RafDriver

Source§

impl SupportsStaticProperty for RafDriver

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> 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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more