MCPcopy Create free account
hub / github.com/error311/FileRise / animateCardsOutOfHeaderThen

Function animateCardsOutOfHeaderThen

public/js/dragAndDrop.js:690–889  ·  view source on GitHub ↗
(done)

Source from the content-addressed store, hash-verified

688
689// Animate cards "flying out" of header icons back into their zones.
690function 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();

Callers 1

setZonesCollapsedFunction · 0.85

Calls 13

getHeaderDropAreaFunction · 0.85
doneFunction · 0.85
getCardsFunction · 0.85
getSidebarFunction · 0.85
getTopZoneFunction · 0.85
readLayoutFunction · 0.85
getZoneOrderFunction · 0.85
getLeftColFunction · 0.85
getRightColFunction · 0.85
getZoneHostFunction · 0.85
createCardGhostFunction · 0.85

Tested by

no test coverage detected