Skip to content

Commit 99b30be

Browse files
committed
refactor(modal): simplify modal opening
1 parent a8bc5b9 commit 99b30be

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

packages/kit-headless/src/components/modal/modal-behavior.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,10 @@ export function closing(modal: HTMLDialogElement, onClose$?: QRL<() => void>) {
175175
}
176176

177177
/*
178-
* Listens for animation/transition events in order to
179-
* remove Animation-CSS-Classes after animation/transition ended.
178+
* Adds CSS-Class to support modal-opening-animation
180179
*/
181180
export function opening(modal: HTMLDialogElement) {
182-
if (!modal) {
183-
return;
184-
}
181+
if (!modal) return;
185182

186183
modal.classList.add('modal-showing');
187-
188-
const { animationDuration, transitionDuration } = getComputedStyle(modal);
189-
190-
const runAnimationEnd = () => {
191-
modal.classList.remove('modal-showing');
192-
modal.removeEventListener('animationend', runAnimationEnd);
193-
};
194-
195-
const runTransitionEnd = () => {
196-
modal.removeEventListener('transitionend', runTransitionEnd);
197-
};
198-
199-
if (animationDuration !== '0s') {
200-
modal.addEventListener('animationend', runAnimationEnd);
201-
} else if (transitionDuration !== '0s') {
202-
modal.addEventListener('transitionend', runTransitionEnd);
203-
} else {
204-
modal.classList.remove('modal-showing');
205-
}
206184
}

0 commit comments

Comments
 (0)