Skip to content

Instantly share code, notes, and snippets.

@onassar
Created September 7, 2022 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onassar/bdefa17ca9dac39d2d556b209ab42851 to your computer and use it in GitHub Desktop.
Save onassar/bdefa17ca9dac39d2d556b209ab42851 to your computer and use it in GitHub Desktop.
/**
* __getTopRightPosition
*
* @see https://www.figma.com/plugin-docs/api/properties/figma-showui/
* @access private
* @param Number width
* @param Number height
* @return Object
*/
var __getTopRightPosition = function(width, height) {
var zoom = figma.viewport.zoom,
ruleSize = 20,
padding = 20,
bounds = figma.viewport.bounds,
x = (bounds.x + bounds.width) - (width / zoom) - (padding / zoom),
y = bounds.y + (ruleSize / zoom) + (padding / zoom),
position = {};
position.x = Math.floor(x);
position.y = Math.floor(y);
return position;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment