phetsims / paper-land

Build and explore multimodal web interactives with pieces of paper!
https://phetsims.github.io/paper-land/
MIT License
19 stars 3 forks source link

Back to back setImage calls makes the Interactive Display page unresponsive #222

Closed jessegreenberg closed 9 months ago

jessegreenberg commented 9 months ago

Setting images back to back breaks the Interactive Display page

This code works

if ( booleanComponent ) {
  setImage( 'on-bulb.png' );    
}
else {
    setImage( 'off-bulb.png' );
}

This code makes the board page unresponsive:

  setImage( 'on-bulb.png' );
  setImage( 'off-bulb.png' );
jessegreenberg commented 9 months ago

This was tricky but it has been fixed. The solution for re-positioning images after they load from setImage (because loading is not synchronous) was causing an infinite loop. Actually using async/await if a better way to do it and fixed the problem. Closing.