Skip to main content

use_sheet_lifecycle

Function use_sheet_lifecycle 

Source
fn use_sheet_lifecycle(
    open: RwSignal<bool>,
    trigger_id: String,
    focus_targets: Vec<String>,
    on_close_start: impl Fn() + Send + Sync + 'static,
    on_closed: impl Fn() + Send + Sync + 'static,
) -> (RwSignal<bool>, Callback<()>)
Expand description

两种抽屉共用的开合生命周期,返回 (closing, close):

  • open 翻转时锁定 / 解除页面滚动,打开时按 focus_targets 顺序聚焦第一个匹配项;
  • 卸载时解除滚动锁(例如抽屉打开时跳到别的页面);
  • close:播放退出动画(SHEET_EXIT_MS)后真正关闭,焦点立即还给 trigger_id; on_close_start 在动画开始前调用(清掉进行中的拖拽),on_closed 在关闭后调用(复位位移);
  • 通过 context 提供 SheetClose 给抽屉内容。