visit
I thought it was no big deal, opened a Figma, took the source code of the SVG, threw it in and .... didn't work 😔
Researching the problem, it turned out that the library that animates SVG works directly with rect
elements inside the same SVG. Well again no problem I thought :), let's just rename all layers to Rect and we'll be happy.
Renamed, I looked at the SVG source code and I don't see rect
:(
It turned out that for SVG to understand the elements we want to animate as recr
we need to draw them.... drum roll - through Frames.
const selectedNodes = figma.currentPage.selection;
if (selectedNodes.length === 0) {
figma.notify("Please select at least one layer.");
} else {
selectedNodes.forEach(node => {
const frame = figma.createFrame();
frame.resize(node.width, node.height);
frame.x = node.x;
frame.y = node.y;
frame.appendChild(node);
node.x = 0;
node.y = 0;
});
figma.notify("All selected layers are wrapped in frames!");
}
figma.closePlugin();