pub struct Presence { /* private fields */ }Expand description
显隐过渡状态机(实现元素的“退场动画”:隐藏后仍保持挂载直至淡出/滑出完成)。
ⓘ
// 渲染期:
let now = cx.now_ms();
if self.popup.is_mounted(now) {
root = root.child(cx, div().opacity(self.popup.opacity(now)).mt(self.popup.offset(now, 16)));
}
if self.popup.is_animating(now) { cx.request_frame(); }
// 事件中:self.popup.hide(acx.now_ms());Implementations§
Source§impl Presence
impl Presence
Sourcepub const fn new(visible: bool, duration_ms: u16) -> Self
pub const fn new(visible: bool, duration_ms: u16) -> Self
创建初始显隐状态为 visible、过渡时长为 duration_ms 的状态机。
Sourcepub const fn with_easing(self, easing: Easing) -> Self
pub const fn with_easing(self, easing: Easing) -> Self
设置显隐过渡缓动曲线。
Sourcepub const fn is_visible(&self) -> bool
pub const fn is_visible(&self) -> bool
目标状态是否为可见。
Sourcepub fn set_visible(&mut self, now_ms: u32, visible: bool)
pub fn set_visible(&mut self, now_ms: u32, visible: bool)
显式设置显隐状态。
Sourcepub fn is_mounted(&self, now_ms: u32) -> bool
pub fn is_mounted(&self, now_ms: u32) -> bool
元素是否仍需挂载渲染(可见,或正在执行退场过渡)。
Sourcepub fn is_animating(&self, now_ms: u32) -> bool
pub fn is_animating(&self, now_ms: u32) -> bool
显隐过渡是否正在进行(渲染期据此调用 cx.request_frame())。
Sourcepub fn progress_256(&self, now_ms: u32) -> i32
pub fn progress_256(&self, now_ms: u32) -> i32
当前显现进度(0 完全隐藏 ~ 256 完全显示)。
Trait Implementations§
impl Copy for Presence
impl Eq for Presence
impl StructuralPartialEq for Presence
Auto Trait Implementations§
impl Forget for Presence
impl Freeze for Presence
impl Move for Presence
impl RefUnwindSafe for Presence
impl Send for Presence
impl Sync for Presence
impl Unpin for Presence
impl UnsafeUnpin for Presence
impl UnwindSafe for Presence
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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) 时执行闭包修饰自身,否则原样返回。