I’m looking for a way to set a variable on prototype start or onLoad? I know I can set the default value but there are some cases where I would like to add some logic onStart or onLoad. Does this functionality exist? Am I missing something?
There are no interactions/conditionals yet for onStart or onLoad, so one way I’ve gone about setting variables/running conditionals at the start of a prototype is using a starter frame, and when a user clicks “start” I set all the variables I need.
You can see an example of this approach in my “Dropdowns: Dual Filtering” community file: https://www.figma.com/community/file/1293788953336727684/dropdowns-dual-filtering.
I usually set an initial variable with the action “After delay” and set the timing to “1ms”.
I use the 1ms delay hack (Still no 0ms delay after all these years? No “instant”?) to set booleans to control keyboard navigation with if/then and if you’re going through the prototype rapidly with the keyboard, the variable doesn’t get set in time and the next keypress leads to the wrong destination.
an onStart action is desperately needed.
I also use 1ms “After delay” which looks like a hack. I’m pretty happy with this, but I’d rather use something more direct, like “onLoad”/“onStart”.
But that would require introducing a completely new trigger on the base level, wouldn’t it? It doesn’t seem like the current Figma model allows for custom trigger list for different elements. And should such a trigger be called on every load of an element or only on its first appearance?
I think it would be more reasonable to add initialization logic to the flows instead.