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