Skip to main content
Question

Loader image not loading properly in Figma plugin

  • April 29, 2024
  • 1 reply
  • 114 views

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.

This topic has been closed for comments

1 reply

Gleb
  • Power Member
  • 4706 replies
  • April 29, 2024

This part of code looks fine.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings