pub struct MotionCache { /* private fields */ }Expand description
跨帧状态、物理弹簧过渡、幽灵退场快照与弹性滚动缓存池(MotionCache)。
Implementations§
Source§impl MotionCache
impl MotionCache
Sourcepub const fn ime_caret_bounds(&self) -> Option<Region>
pub const fn ime_caret_bounds(&self) -> Option<Region>
读取本帧捕获到的精确文本输入光标逻辑屏幕矩形(无活跃文本光标时返回 None)。
Sourcepub fn set_reduced_motion(&mut self, reduced: bool)
pub fn set_reduced_motion(&mut self, reduced: bool)
配置无障碍「减弱动态效果」(开启后自动关闭几何位移动画、橡皮筋越界回弹与幽灵滑出)。
Sourcepub const fn reduced_motion(&self) -> bool
pub const fn reduced_motion(&self) -> bool
查询当前是否开启了「减弱动态效果」。
Sourcepub fn active_ghost_count(&self) -> usize
pub fn active_ghost_count(&self) -> usize
查询当前正在播放退场动画的幽灵快照数量。
Sourcepub fn current_velocity(&self, id: u32) -> Option<(i32, i32)>
pub fn current_velocity(&self, id: u32) -> Option<(i32, i32)>
只读查询指定元素 ID 的当前二阶弹簧瞬时水平/垂直速度 (vx_px_per_s, vy_px_per_s)。
Sourcepub fn tick(&mut self, dt_ms: u16) -> bool
pub fn tick(&mut self, dt_ms: u16) -> bool
推进所有活跃过渡动画(含二阶定点数弹簧)、幽灵退场快照与弹性滚动物理(dt_ms 毫秒)。
返回本帧是否有动画、幽灵退场或滚动物理发生步进。
Sourcepub fn has_active_animations(&self) -> bool
pub fn has_active_animations(&self) -> bool
是否存在正在进行的过渡动画、幽灵退场或弹性惯性滚动。
Sourcepub fn transition_count(&self) -> usize
pub fn transition_count(&self) -> usize
当前占用的过渡动画槽位数量(用于容量监控与测试)。
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
帧求解开始:清除所有槽位与幽灵快照的访问标记(由布局求解器自动调用)。
Sourcepub fn finish_all(&mut self)
pub fn finish_all(&mut self)
立即结束所有单次过渡动画并停留在各自目标状态(用于“减少动态效果”无障碍设置或测试快进)。
Sourcepub fn current_state(&self, id: u32) -> Option<MotionState>
pub fn current_state(&self, id: u32) -> Option<MotionState>
只读查询指定 ID 当前插值中的视觉状态(不推进时间、不更新访问标记)。
Sourcepub fn resolve(
&mut self,
id: u32,
target: MotionState,
spec: Option<TransitionSpec>,
) -> MotionState
pub fn resolve( &mut self, id: u32, target: MotionState, spec: Option<TransitionSpec>, ) -> MotionState
解析并更新带 ID 节点的跨帧过渡属性(颜色、几何、不透明度、入场、延迟、循环与二阶弹簧速度继承)。
Sourcepub fn resolve_div(
&mut self,
id: u32,
target_bounds: Region,
target_bg: Color,
target_border: Color,
spec: Option<TransitionSpec>,
) -> (Region, Color, Color)
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 节点的跨帧过渡属性(兼容旧接口,不含不透明度)。
Sourcepub fn resolve_text_color(
&mut self,
id: u32,
target_color: Color,
duration_ms: u16,
) -> Color
pub fn resolve_text_color( &mut self, id: u32, target_color: Color, duration_ms: u16, ) -> Color
解析并更新文本颜色跨帧平滑过渡。
Sourcepub fn resolve_text_color_with(
&mut self,
id: u32,
target_color: Color,
parent: TransitionSpec,
) -> Color
pub fn resolve_text_color_with( &mut self, id: u32, target_color: Color, parent: TransitionSpec, ) -> Color
按父容器过渡配置(时长、缓动、延迟)解析文本颜色跨帧过渡。
Sourcepub fn scroll_offset(&self, id: u32) -> i16
pub fn scroll_offset(&self, id: u32) -> i16
获取指定滚动容器 ID 的当前有效滚动偏移量(含橡皮筋越界弹性位移,单位像素)。
Sourcepub fn scroll_overscroll(&self, id: u32) -> i16
pub fn scroll_overscroll(&self, id: u32) -> i16
获取指定滚动容器当前的橡皮筋越界弹性位移(像素;0 表示处于正常区间内)。
Sourcepub fn apply_scroll_drag(
&mut self,
id: u32,
delta_scroll: i16,
max_scroll: i16,
viewport_dim: i16,
)
pub fn apply_scroll_drag( &mut self, id: u32, delta_scroll: i16, max_scroll: i16, viewport_dim: i16, )
应用触摸/手势拖拽滚动增量(带 @use-gesture 双曲橡皮筋越界阻尼)。
Sourcepub fn release_scroll_drag(
&mut self,
id: u32,
release_velocity_y: i16,
max_scroll: i16,
)
pub fn release_scroll_drag( &mut self, id: u32, release_velocity_y: i16, max_scroll: i16, )
结束触摸/手势拖拽并移交瞬时速度:若当前处于越界橡皮筋态则将速度注入临界阻尼回弹弹簧,否则进入惯性衰减。
Sourcepub fn set_scroll_offset(&mut self, id: u32, offset_y: i16)
pub fn set_scroll_offset(&mut self, id: u32, offset_y: i16)
设置指定滚动容器 ID 的垂直滚动偏移量(像素)。
Sourcepub fn set_scroll_inertia(&mut self, id: u32, velocity_y: i16, max_scroll: i16)
pub fn set_scroll_inertia(&mut self, id: u32, velocity_y: i16, max_scroll: i16)
设置滚动容器的最大可滚动范围与惯性速度。
Trait Implementations§
Source§impl Debug for MotionCache
impl Debug for MotionCache
Auto Trait Implementations§
impl Forget for MotionCache
impl Freeze for MotionCachewhere
*const u8 is !null: Freeze,
PhantomData<ActiveTransition>: Freeze,
PhantomData<ScrollEntry>: Freeze,
PhantomData<GhostEntry>: Freeze,
impl Move for MotionCache
impl RefUnwindSafe for MotionCache
impl Send for MotionCachewhere
RawVecInner: Send,
impl Sync for MotionCachewhere
RawVecInner: Sync,
impl Unpin for MotionCache
impl UnsafeUnpin for MotionCachewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<ActiveTransition>: UnsafeUnpin,
PhantomData<ScrollEntry>: UnsafeUnpin,
PhantomData<GhostEntry>: UnsafeUnpin,
impl UnwindSafe for MotionCachewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
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
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
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。