From 94dc8e262ca692fe25723b11a218bf703e52c0b8 Mon Sep 17 00:00:00 2001 From: "Andrew R. Powers" Date: Thu, 14 Dec 2023 17:11:43 -0800 Subject: [PATCH] Handle case when element is undefined --- src/Plugins/SwapAnimation/SwapAnimation.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Plugins/SwapAnimation/SwapAnimation.ts b/src/Plugins/SwapAnimation/SwapAnimation.ts index 87acf298..3a335e07 100644 --- a/src/Plugins/SwapAnimation/SwapAnimation.ts +++ b/src/Plugins/SwapAnimation/SwapAnimation.ts @@ -120,8 +120,9 @@ function animate( to: HTMLElement, {duration, easingFunction, horizontal}: Options, ) { + for (const element of [from, to]) { - element.style.pointerEvents = 'none'; + element?.style.pointerEvents = 'none'; } if (horizontal) { @@ -136,9 +137,9 @@ function animate( requestAnimationFrame(() => { for (const element of [from, to]) { - element.addEventListener('transitionend', resetElementOnTransitionEnd); - element.style.transition = `transform ${duration}ms ${easingFunction}`; - element.style.transform = ''; + element?.addEventListener('transitionend', resetElementOnTransitionEnd); + element?.style.transition = `transform ${duration}ms ${easingFunction}`; + element?.style.transform = ''; } }); }