From fac2394e4de241a202afbe9274eeddfbc6ad2942 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sat, 21 Sep 2024 11:07:05 +0800 Subject: style: add comment for animation --- src/dumbymap.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index dd96437..b1ba0c9 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs @@ -270,16 +270,19 @@ export const generateMaps = async (container, callback) => { resume: true }) } else if (showcase.contains(target)) { + // Check placeholder is inside Semantic HTML 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 }) + // Consider animation may fail, write callback const afterAnimation = () => { placeholder.parentElement.replaceChild(target, placeholder) target.style = placeholder.style.cssText placeholder.remove() } - if (animation) { animation.finished .then(afterAnimation) -- cgit v1.2.3-70-g09d2