mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
perf(overlay): prevent layout thrashing
This commit is contained in:
@ -100,12 +100,6 @@ async function overlayAnimation(
|
||||
baseEl: HTMLElement,
|
||||
opts: any
|
||||
): Promise<void> {
|
||||
if (overlay.keyboardClose) {
|
||||
const activeElement = baseEl.ownerDocument.activeElement as HTMLElement;
|
||||
if (activeElement) {
|
||||
activeElement.blur();
|
||||
}
|
||||
}
|
||||
if (overlay.animation) {
|
||||
overlay.animation.destroy();
|
||||
overlay.animation = undefined;
|
||||
@ -117,6 +111,14 @@ async function overlayAnimation(
|
||||
if (!overlay.willAnimate) {
|
||||
animation.duration(0);
|
||||
}
|
||||
if (overlay.keyboardClose) {
|
||||
animation.beforeAddWrite(() => {
|
||||
const activeElement = baseEl.ownerDocument.activeElement as HTMLElement;
|
||||
if (activeElement && activeElement.matches('input, ion-input, ion-textarea')) {
|
||||
activeElement.blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
await animation.playAsync();
|
||||
|
||||
animation.destroy();
|
||||
|
Reference in New Issue
Block a user