Spaces:
Running
Running
fix: frame overlap — position all frames after content is built
Browse filesFrames were positioned at creation time with estimated heights,
then resized to actual content — causing overlaps. Now all frames
are collected in an array and positioned sequentially at the very
end, using their actual rendered heights + 40px gap between each.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
output_json/figma-plugin-extracted/figma-design-token-creator 5/src/code.js
CHANGED
|
@@ -858,19 +858,20 @@ figma.ui.onmessage = async function(msg) {
|
|
| 858 |
} catch (e) { sampleFontFamily = 'Inter'; sampleFont = labelFont; sampleFontBold = boldFont; }
|
| 859 |
}
|
| 860 |
|
| 861 |
-
|
|
|
|
| 862 |
|
| 863 |
-
// ── Helper: create a section FRAME ──
|
| 864 |
function createSectionFrame(name, contentHeight) {
|
| 865 |
var frame = figma.createFrame();
|
| 866 |
frame.name = name;
|
| 867 |
frame.resize(FRAME_W, contentHeight);
|
| 868 |
frame.x = 0;
|
| 869 |
-
frame.y =
|
| 870 |
frame.fills = [{ type: 'SOLID', color: { r: 1, g: 1, b: 1 } }];
|
| 871 |
frame.clipsContent = false;
|
| 872 |
specPage.appendChild(frame);
|
| 873 |
-
|
| 874 |
return frame;
|
| 875 |
}
|
| 876 |
|
|
@@ -1282,7 +1283,17 @@ figma.ui.onmessage = async function(msg) {
|
|
| 1282 |
}
|
| 1283 |
}
|
| 1284 |
|
| 1285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1286 |
|
| 1287 |
} catch (error) {
|
| 1288 |
console.error('Error creating visual spec:', error);
|
|
|
|
| 858 |
} catch (e) { sampleFontFamily = 'Inter'; sampleFont = labelFont; sampleFontBold = boldFont; }
|
| 859 |
}
|
| 860 |
|
| 861 |
+
// Collect all frames — position them at the very end
|
| 862 |
+
var allFrames = [];
|
| 863 |
|
| 864 |
+
// ── Helper: create a section FRAME (positioned later) ──
|
| 865 |
function createSectionFrame(name, contentHeight) {
|
| 866 |
var frame = figma.createFrame();
|
| 867 |
frame.name = name;
|
| 868 |
frame.resize(FRAME_W, contentHeight);
|
| 869 |
frame.x = 0;
|
| 870 |
+
frame.y = 0; // will be repositioned at the end
|
| 871 |
frame.fills = [{ type: 'SOLID', color: { r: 1, g: 1, b: 1 } }];
|
| 872 |
frame.clipsContent = false;
|
| 873 |
specPage.appendChild(frame);
|
| 874 |
+
allFrames.push(frame);
|
| 875 |
return frame;
|
| 876 |
}
|
| 877 |
|
|
|
|
| 1283 |
}
|
| 1284 |
}
|
| 1285 |
|
| 1286 |
+
// ══════════════════════════════════════════════════════════
|
| 1287 |
+
// POSITION ALL FRAMES — stack vertically with proper spacing
|
| 1288 |
+
// This runs AFTER all frames are created and resized to actual content.
|
| 1289 |
+
// ══════════════════════════════════════════════════════════
|
| 1290 |
+
var stackY = 0;
|
| 1291 |
+
for (var fi = 0; fi < allFrames.length; fi++) {
|
| 1292 |
+
allFrames[fi].y = stackY;
|
| 1293 |
+
stackY += allFrames[fi].height + SECTION_GAP;
|
| 1294 |
+
}
|
| 1295 |
+
|
| 1296 |
+
figma.ui.postMessage({ type: 'spec-complete', message: 'Visual spec created with ' + allFrames.length + ' section frames!' });
|
| 1297 |
|
| 1298 |
} catch (error) {
|
| 1299 |
console.error('Error creating visual spec:', error);
|