This code loops through the currently selected nodes on the...

March 28, 2023 at 03:33 PM

for (const [index, node] of figma.currentPage.selection.entries()) { const wrapFrame = figma.createFrame() wrapFrame.layoutMode = "HORIZONTAL"; wrapFrame.x = node.parent.x wrapFrame.y = node.parent.y wrapFrame.name = node.name wrapFrame.appendChild(node) }

This code loops through the currently selected nodes on the Figma canvas, and creates a new frame for each one. It then sets the layout mode of the new frame to be "HORIZONTAL", which means that any child nodes added to it will be arranged horizontally.

The x and y coordinates of the new frame are set to match the parent node's coordinates, so that the new frame is positioned in the same place as the original node. The name of the new frame is set to match the name of the original node.

Finally, the original node is appended as a child of the new frame, so that it becomes a part of the horizontal layout inside the new frame.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node