Skip to content

Commit

Permalink
perf(overlay): prevent layout thrashing
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Aug 19, 2018
1 parent ea1c3d4 commit ed5c8eb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/src/utils/overlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit ed5c8eb

Please sign in to comment.