aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dumbymap.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-09-22 17:51:57 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-09-22 17:54:35 +0800
commit516aab9de3d6ad5b52da75666ce9f6531c913be6 (patch)
tree50a36e0129e181f6563046cb5f50ba376eb3305b /src/dumbymap.mjs
parent66b9043665f85a3180d91a63d7cbacd82493c16b (diff)
feat(utils): return empty Animation, not null for DOMRect
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r--src/dumbymap.mjs15
1 files changed, 6 insertions, 9 deletions
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) => {
267 const placeholder = htmlHolder.querySelector(`[data-placeholder="${target.id}"]`) 267 const placeholder = htmlHolder.querySelector(`[data-placeholder="${target.id}"]`)
268 if (!placeholder) throw Error(`Cannot fine placeholder for map "${target.id}"`) 268 if (!placeholder) throw Error(`Cannot fine placeholder for map "${target.id}"`)
269 269
270 // animation from Showcase to placeholder 270 .catch(afterAnimation)
271 const animation = animateRectTransition(target, placeholder.getBoundingClientRect(), { duration: 300 })
272 271
273 // Consider animation may fail, write callback 272 // Consider animation may fail, write callback
274 const afterAnimation = () => { 273 const afterAnimation = () => {
@@ -276,13 +275,11 @@ export const generateMaps = async (container, callback) => {
276 target.style = placeholder.style.cssText 275 target.style = placeholder.style.cssText
277 placeholder.remove() 276 placeholder.remove()
278 } 277 }
279 if (animation) { 278
280 animation.finished 279 // animation from Showcase to placeholder
281 .then(afterAnimation) 280 animateRectTransition(target, placeholder.getBoundingClientRect(), { duration: 300 })
282 .catch(afterAnimation) 281 .finished
283 } else { 282 .finally(afterAnimation)
284 afterAnimation()
285 }
286 } 283 }
287 }) 284 })
288 // }}} 285 // }}}