perf(overlay): prevent layout thrashing

This commit is contained in:
Manu Mtz.-Almeida
2018-08-19 18:58:46 +02:00
parent ea1c3d4100
commit ed5c8ebf09

View File

@ -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();