Hi, I want to resize a node according to some save data whenever the user changes its width or height. So far, I’ve been able to detect it using the documentchange handler and checking for the PROPERTY_CHANGED type (more info in a prev question I posed here)
However, I want to specifically detect if the width or height of the node has changed; I want to resize the height if its width was changed, and vice versa. I’ve read in another article to try setInterval() (article here) but I’d rather avoid it for performance reasons.
Does anyone know of a more effective way to check for this using an event handler?
The thread you linked to only suggested using
setInterval() because there was no
documentchange event in the Plugin API before.
Could you explain what you don’t like about the
Wait, I just figured out that the documentchange event has a properties component that details the type of property change that’s occured
I just realised that the properties component stores an array of strings detailing the types of property changes that’s occured in a node eg when I stretch a rectangle horizontally and vertically, change.properties will look like [‘width’, ‘height’]:
how it looks in Figma console: