Skip to content

Commit 3454da1

Browse files
committed
fix(animation modal): animations stacking unnecessairly
1 parent fa669fb commit 3454da1

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

frontend/src/ts/utils/animated-modal.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ export default class AnimatedModal<
248248
this.focusFirstInput(options?.focusFirstInput);
249249
}, 1);
250250

251+
const hasModalAnimation =
252+
(options?.customAnimation?.modal ??
253+
this.customHideAnimations?.modal) !== undefined;
254+
251255
const modalAnimation = options?.customAnimation?.modal ??
252256
this.customShowAnimations?.modal ?? {
253257
opacity: [0, 1],
@@ -269,10 +273,14 @@ export default class AnimatedModal<
269273
: options?.animationMode ?? "both";
270274

271275
if (animationMode === "both" || animationMode === "none") {
272-
animate(this.modalEl, {
273-
...modalAnimation,
274-
duration: animationMode === "none" ? 0 : modalAnimationDuration,
275-
});
276+
if (hasModalAnimation) {
277+
animate(this.modalEl, {
278+
...modalAnimation,
279+
duration: animationMode === "none" ? 0 : modalAnimationDuration,
280+
});
281+
} else {
282+
this.modalEl.style.opacity = "1";
283+
}
276284

277285
animate(this.wrapperEl, {
278286
...wrapperAnimation,
@@ -322,6 +330,10 @@ export default class AnimatedModal<
322330

323331
await options?.beforeAnimation?.(this.modalEl);
324332

333+
const hasModalAnimation =
334+
(options?.customAnimation?.modal ??
335+
this.customHideAnimations?.modal) !== undefined;
336+
325337
const modalAnimation = options?.customAnimation?.modal ??
326338
this.customHideAnimations?.modal ?? {
327339
opacity: [1, 0],
@@ -351,10 +363,14 @@ export default class AnimatedModal<
351363
: options?.animationMode ?? "both";
352364

353365
if (animationMode === "both" || animationMode === "none") {
354-
animate(this.modalEl, {
355-
...modalAnimation,
356-
duration: animationMode === "none" ? 0 : modalAnimationDuration,
357-
});
366+
if (hasModalAnimation) {
367+
animate(this.modalEl, {
368+
...modalAnimation,
369+
duration: animationMode === "none" ? 0 : modalAnimationDuration,
370+
});
371+
} else {
372+
this.modalEl.style.opacity = "1";
373+
}
358374

359375
animate(this.wrapperEl, {
360376
...wrapperAnimation,

0 commit comments

Comments
 (0)