I am creating a simple Figma plugin. I am trying to show a loader when I click a button to hide the current div and show next div, sort of a new page.
When I add the basic JavaScript statement to show a loader, it is sometimes loading with a delay. It is sometimes showing only just before the transition happens. But sometimes it shows immediately when I click on the button.
Here is my code.
document.getElementById(ābuttonCalculateā).onclick = () => {
document.getElementById(āfigsuLoaderā).style.display = āblockā;
parent.postMessage({ pluginMessage: { type: ācalculate-weightā} }, ā*ā);
onmessage = (event) => {
if (event.data.pluginMessage.type !== āerrorā) {
document.getElementById(āfigsuLoaderā).style.display = ānoneā;
}
}
}
I am not sure if its because of the delay due to content loaded in iFrame. I debugged this in depth. But I am not able to get a resolution for this. Please help me here.
