Skip to main content

MotionCache

Struct MotionCache 

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

跨帧状态与过渡动画插值池(MotionCache)。

维护活跃属性过渡动画(no_std 下最多 16 个,std 下按需扩容;每帧求解后自动回收 已从元素树中消失的槽位)以及虚拟滚动列表的滚动偏移量与惯性速度。

Implementations§

Source§

impl MotionCache

Source

pub const fn new() -> Self

创建空的跨帧状态缓存池。

Source

pub fn tick(&mut self, dt_ms: u16) -> bool

推进所有活跃过渡动画与惯性滚动的时间戳(dt_ms 毫秒)。 返回本帧是否有动画或惯性滚动发生步进。

Source

pub fn has_active_animations(&self) -> bool

是否存在正在进行的过渡动画或惯性滚动。

Source

pub fn transition_count(&self) -> usize

当前占用的过渡动画槽位数量(用于容量监控与测试)。

Source

pub fn begin_frame(&mut self)

帧求解开始:清除所有槽位的访问标记(由布局求解器自动调用)。

Source

pub fn end_frame(&mut self)

帧求解结束:回收本帧未被访问(已从元素树中移除)的过渡动画与长期陈旧滚动槽位,防止槽位泄漏与容量耗尽。

Source

pub fn finish_all(&mut self)

立即结束所有单次过渡动画并停留在各自目标状态(用于“减少动态效果”无障碍设置或测试快进)。

Source

pub fn current_state(&self, id: u32) -> Option<MotionState>

只读查询指定 ID 当前插值中的视觉状态(不推进时间、不更新访问标记)。

Source

pub fn resolve( &mut self, id: u32, target: MotionState, spec: Option<TransitionSpec>, ) -> MotionState

解析并更新带 ID 节点的跨帧过渡属性(颜色、几何、不透明度、入场、延迟与循环)。

Source

pub fn resolve_div( &mut self, id: u32, target_bounds: Region, target_bg: Color, target_border: Color, spec: Option<TransitionSpec>, ) -> (Region, Color, Color)

解析并更新带 ID 的 Div 节点的跨帧过渡属性(兼容旧接口,不含不透明度)。

Source

pub fn resolve_text_color( &mut self, id: u32, target_color: Color, duration_ms: u16, ) -> Color

解析并更新文本颜色跨帧平滑过渡。

Source

pub fn resolve_text_color_with( &mut self, id: u32, target_color: Color, parent: TransitionSpec, ) -> Color

按父容器过渡配置(时长、缓动、延迟)解析文本颜色跨帧过渡。

Source

pub fn scroll_offset(&self, id: u32) -> i16

获取指定滚动容器 ID 的当前垂直滚动偏移量(像素)。

Source

pub fn set_scroll_offset(&mut self, id: u32, offset_y: i16)

设置指定滚动容器 ID 的垂直滚动偏移量(像素)。

Source

pub fn set_scroll_inertia(&mut self, id: u32, velocity_y: i16, max_scroll: i16)

设置滚动容器的最大可滚动范围与惯性速度。

Trait Implementations§

Source§

impl Debug for MotionCache

Source§

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

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

impl Default for MotionCache

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,