phetsims / gas-properties

"Gas Properties" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 6 forks source link

Particles are not redistributed when the container is resized with the sim paused. #267

Closed pixelzoom closed 5 months ago

pixelzoom commented 5 months ago

Noticed while working on https://github.com/phetsims/gas-properties/issues/263.

This problem was introduced sometime between 1.1.0-dev.3 (7/8/2020) and 1.1.0-dev.4 (11/17/22).

Steps to reproduce:

  1. Start the sim
  2. Go to the Ideal screen
  3. Add particles to the container. Wait for them to disperse.
  4. Pause the sim.
  5. Make the container smaller. The particles are not redistributed, and particles appear to be outside the container, as in the screenshot below.
screenshot_3373
pixelzoom commented 5 months ago

Fixed in the above commit. The model was being updated correctly, but I needed to explicitly tell the view to update when the sim is paused. In IdealGasLawScreenView:

          model.particleSystem.redistributeParticles( model.container.widthProperty.value / startContainerWidth );
+         if ( !model.isPlayingProperty.value ) {
+           particleSystemNode.update();
+         }

Closing.