Skip to content

Instantly share code, notes, and snippets.

@LukeFinch
Created April 8, 2021 17:16
Show Gist options
  • Save LukeFinch/3defcdcfcc61a46a5fb7acb29562eb56 to your computer and use it in GitHub Desktop.
Save LukeFinch/3defcdcfcc61a46a5fb7acb29562eb56 to your computer and use it in GitHub Desktop.
Resizes a node to less than 0.01 px
function zeroResize(node, width, height){
//Workaround to resize a node, if its size is less than 0.01
node.resize(width < 0.01 ? 1 : width,height < 0.01 ? 1 : height)
if(width < 0.01 || height < 0.01){
let dummy = figma.createRectangle()
dummy.resize(width < 0.01 ? 1/width : width,height < 0.01 ? 1/height : height)
let group: GroupNode = figma.group([node,dummy],figma.currentPage)
group.resize(width < 0.01 ? 1 : width,height < 0.01 ? 1 : height)
group.parent.appendChild(node)
group.remove()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment