Skip to content

Commit cd84ab6

Browse files
committed
refactor(overlays): add RAF
1 parent 6b8bd24 commit cd84ab6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/src/utils/overlays.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export const createOverlay = <T extends HTMLIonOverlayElement>(
114114
return window.customElements.whenDefined(tagName).then(() => {
115115
const element = document.createElement(tagName) as HTMLIonOverlayElement;
116116
element.classList.add('overlay-hidden');
117-
element.setAttribute('aria-hidden', 'true');
118117

119118
/**
120119
* Convert the passed in overlay options into props
@@ -745,7 +744,6 @@ const overlayAnimation = async (
745744
): Promise<boolean> => {
746745
// Make overlay visible in case it's hidden
747746
baseEl.classList.remove('overlay-hidden');
748-
baseEl.removeAttribute('aria-hidden');
749747

750748
const aniRoot = overlay.el;
751749
const animation = animationBuilder(aniRoot, opts);
@@ -755,6 +753,9 @@ const overlayAnimation = async (
755753
}
756754

757755
animation.beforeAddWrite(() => {
756+
console.log('beforeAddWrite');
757+
baseEl.setAttribute('aria-hidden', 'true');
758+
758759
if (overlay.keyboardClose) {
759760
const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement;
760761
if (activeElement?.matches('input,ion-input, ion-textarea')) {
@@ -763,6 +764,13 @@ const overlayAnimation = async (
763764
}
764765
});
765766

767+
animation.afterAddWrite(() => {
768+
requestAnimationFrame(() => {
769+
baseEl.removeAttribute('aria-hidden');
770+
console.log('afterAddWrite');
771+
});
772+
});
773+
766774
const activeAni = activeAnimations.get(overlay) || [];
767775
activeAnimations.set(overlay, [...activeAni, animation]);
768776

0 commit comments

Comments
 (0)