iter(g292): toast 溢出改走退场
This commit is contained in:
@@ -37,7 +37,8 @@ export function showToast(props: ToastProps): HTMLElement {
|
||||
props.closable ? h('button', { type: 'button', class: 'ua-toast-close', 'aria-label': '关闭提示', onClick: () => dismiss(item) }, '×') : null,
|
||||
);
|
||||
const stack = ensureHost();
|
||||
if (stack.childElementCount >= MAX_STACK) stack.firstElementChild?.remove(); // 超过上限直接挤掉最早一条
|
||||
const oldest = stack.childElementCount >= MAX_STACK ? stack.firstElementChild : null;
|
||||
if (oldest) dismiss(oldest as HTMLElement); // 超出上限让最早一条走正常退场:直接 remove 会让它凭空消失,与手动关闭两种手感
|
||||
|
||||
stack.appendChild(item);
|
||||
requestAnimationFrame(() => item.classList.add('ua-open')); // 下一帧入场,保证过渡生效
|
||||
|
||||
Reference in New Issue
Block a user