From 516aab9de3d6ad5b52da75666ce9f6531c913be6 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 22 Sep 2024 17:51:57 +0800 Subject: feat(utils): return empty Animation, not null for DOMRect --- src/dumbymap.mjs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/dumbymap.mjs') diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 7079286..1db8437 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs @@ -267,8 +267,7 @@ export const generateMaps = async (container, callback) => { const placeholder = htmlHolder.querySelector(`[data-placeholder="${target.id}"]`) if (!placeholder) throw Error(`Cannot fine placeholder for map "${target.id}"`) - // animation from Showcase to placeholder - const animation = animateRectTransition(target, placeholder.getBoundingClientRect(), { duration: 300 }) + .catch(afterAnimation) // Consider animation may fail, write callback const afterAnimation = () => { @@ -276,13 +275,11 @@ export const generateMaps = async (container, callback) => { target.style = placeholder.style.cssText placeholder.remove() } - if (animation) { - animation.finished - .then(afterAnimation) - .catch(afterAnimation) - } else { - afterAnimation() - } + + // animation from Showcase to placeholder + animateRectTransition(target, placeholder.getBoundingClientRect(), { duration: 300 }) + .finished + .finally(afterAnimation) } }) // }}} -- cgit v1.2.3-70-g09d2