Skip to content

Commit a8bc5b9

Browse files
committed
refactor(modal): register animated/transitioned once
1 parent 1108fa8 commit a8bc5b9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,17 @@ export function closing(modal: HTMLDialogElement, onClose$?: QRL<() => void>) {
157157
const runAnimationEnd = () => {
158158
modal.classList.remove('modal-closing');
159159
closeModal(modal, onClose$);
160-
modal.removeEventListener('animationend', runAnimationEnd);
161160
};
162161

163162
const runTransitionEnd = () => {
164163
modal.classList.remove('modal-closing');
165164
closeModal(modal, onClose$);
166-
modal.removeEventListener('transitionend', runTransitionEnd);
167165
};
168166

169167
if (animationDuration !== '0s') {
170-
modal.addEventListener('animationend', runAnimationEnd);
168+
modal.addEventListener('animationend', runAnimationEnd, { once: true });
171169
} else if (transitionDuration !== '0s') {
172-
modal.addEventListener('transitionend', runTransitionEnd);
170+
modal.addEventListener('transitionend', runTransitionEnd, { once: true });
173171
} else {
174172
modal.classList.remove('modal-closing');
175173
closeModal(modal, onClose$);

0 commit comments

Comments
 (0)