diff --git a/src/Plugins/SwapAnimation/SwapAnimation.js b/src/Plugins/SwapAnimation/SwapAnimation.js index d8900278..fcf78206 100644 --- a/src/Plugins/SwapAnimation/SwapAnimation.js +++ b/src/Plugins/SwapAnimation/SwapAnimation.js @@ -108,24 +108,30 @@ export default class SwapAnimation extends AbstractPlugin { */ function animate(from, to, {duration, easingFunction, horizontal}) { for (const element of [from, to]) { - element.style.pointerEvents = 'none'; + if (element && element.style) { + element.style.pointerEvents = 'none'; + } } - if (horizontal) { - const width = from.offsetWidth; - from.style.transform = `translate3d(${width}px, 0, 0)`; - to.style.transform = `translate3d(-${width}px, 0, 0)`; - } else { - const height = from.offsetHeight; - from.style.transform = `translate3d(0, ${height}px, 0)`; - to.style.transform = `translate3d(0, -${height}px, 0)`; + if (from && to && from.style && to.style) { + if (horizontal) { + const width = from.offsetWidth; + from.style.transform = `translate3d(${width}px, 0, 0)`; + to.style.transform = `translate3d(-${width}px, 0, 0)`; + } else { + const height = from.offsetHeight; + from.style.transform = `translate3d(0, ${height}px, 0)`; + to.style.transform = `translate3d(0, -${height}px, 0)`; + } } requestAnimationFrame(() => { for (const element of [from, to]) { - element.addEventListener('transitionend', resetElementOnTransitionEnd); - element.style.transition = `transform ${duration}ms ${easingFunction}`; - element.style.transform = ''; + if (element && element.style && element.addEventListener) { + element.addEventListener('transitionend', resetElementOnTransitionEnd); + element.style.transition = `transform ${duration}ms ${easingFunction}`; + element.style.transform = ''; + } } }); }