diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-23 00:51:22 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-23 12:56:33 +0800 |
commit | 5eefd9c2e4f948cddecf313231afdc62aa1531cd (patch) | |
tree | 36e91cec8cb9db029adf56462d77b53fb17748c8 /src/dumbymap.mjs | |
parent | 911f25e922d47e12c07cc5285d849d2dea10e44e (diff) |
feat(layout): transition to reduce height of empty block
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r-- | src/dumbymap.mjs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 9665c9c..42a507f 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -250,9 +250,15 @@ export const generateMaps = async (container, callback) => { | |||
250 | // Placeholder for map in Showcase, it should has the same DOMRect | 250 | // Placeholder for map in Showcase, it should has the same DOMRect |
251 | const placeholder = target.cloneNode(true) | 251 | const placeholder = target.cloneNode(true) |
252 | placeholder.classList.remove('map-container') | 252 | placeholder.classList.remove('map-container') |
253 | placeholder.setAttribute('data-placeholder', target.id) | ||
254 | target.parentElement.replaceChild(placeholder, target) | 253 | target.parentElement.replaceChild(placeholder, target) |
255 | 254 | ||
255 | // HACK Trigger CSS transition, if placeholde is the olny chil element in block, | ||
256 | // reduce its height to zero. | ||
257 | // To make sure the original height of placeholder is applied, callBoundingClientRect() seems work(Why?). | ||
258 | // then set data-attribute for CSS selector to change height to 0 | ||
259 | placeholder.getBoundingClientRect() | ||
260 | placeholder.setAttribute('data-placeholder', target.id) | ||
261 | |||
256 | // To fit showcase, remove all inline style | 262 | // To fit showcase, remove all inline style |
257 | target.removeAttribute('style') | 263 | target.removeAttribute('style') |
258 | showcase.appendChild(target) | 264 | showcase.appendChild(target) |