(done)
| 688 | |
| 689 | // Animate cards "flying out" of header icons back into their zones. |
| 690 | function animateCardsOutOfHeaderThen(done) { |
| 691 | const header = getHeaderDropArea(); |
| 692 | if (!header) { done(); return; } |
| 693 | |
| 694 | const cards = getCards().filter(c => c && c.headerIconButton); |
| 695 | if (!cards.length) { done(); return; } |
| 696 | |
| 697 | // Make sure target containers are visible so their rects are non-zero. |
| 698 | const sb = getSidebar(); |
| 699 | const top = getTopZone(); |
| 700 | if (sb) sb.style.display = ''; |
| 701 | if (top) top.style.display = ''; |
| 702 | |
| 703 | const SAFE_TOP = 16; |
| 704 | const START_OFFSET_Y = 95; // a touch closer to header |
| 705 | |
| 706 | const layout = readLayout(); |
| 707 | const plan = []; |
| 708 | |
| 709 | cards.forEach(card => { |
| 710 | const iconBtn = card.headerIconButton; |
| 711 | if (!iconBtn) return; |
| 712 | const zoneId = resolveTargetZoneForExpand(card.id); |
| 713 | if (!zoneId) return; |
| 714 | plan.push({ card, iconBtn, zoneId }); |
| 715 | }); |
| 716 | |
| 717 | if (!plan.length) { |
| 718 | done(); |
| 719 | return; |
| 720 | } |
| 721 | |
| 722 | const savedHeights = {}; |
| 723 | CARD_IDS.forEach(id => { |
| 724 | const val = parseFloat($(id)?.dataset.lastHeight || ''); |
| 725 | savedHeights[id] = (!Number.isNaN(val) && val > 0) ? val : 190; |
| 726 | }); |
| 727 | |
| 728 | const sidebarOrder = getZoneOrder(layout, ZONES.SIDEBAR); |
| 729 | const fallbackSidebarOrder = sidebarOrder.length ? sidebarOrder : CARD_IDS; |
| 730 | const ghosts = []; |
| 731 | |
| 732 | // Reserve top-zone height up front so the file list resizes BEFORE the ghosts land. |
| 733 | __cleanupTopZonePreExpand = null; |
| 734 | if (top) { |
| 735 | const targetsTop = plan.filter(p => p.zoneId === ZONES.TOP_LEFT || p.zoneId === ZONES.TOP_RIGHT); |
| 736 | if (targetsTop.length) { |
| 737 | const prevMinHeight = top.style.minHeight; |
| 738 | const reserved = Math.max( |
| 739 | 220, |
| 740 | ...targetsTop.map(p => savedHeights[p.card.id] || 190) |
| 741 | ); |
| 742 | |
| 743 | top.style.display = ''; |
| 744 | top.style.minHeight = `${reserved}px`; |
| 745 | void top.offsetHeight; |
| 746 | |
| 747 | const left = getLeftCol(); |
no test coverage detected