phetsims/collision-lab

Dragging or altering balls sometimes pauses sim

Closed this issue · 7 comments

Device
iPad 6th Gen
OS
iPadOS 14.3
Browser
Safari
Problem Description
For phetsims/qa#599. Sometimes, when dragging a ball or changing its mass/velocity when the sim is running, the sim pauses when you are finished, rather than resuming as it normally does. It seems this occurs if the sim is running one of the pre-set experiments on the inelastic screen.
Steps to Reproduce

  1. Go to the Inelastic screen
  2. Select one of the preset setups
  3. Press play
  4. While playing, grab one of the balls and move it

Visuals

Image.from.iOS.MP4

This may be happening due to the fact that the sim seems to pause when you switch between presets and/or custom. Making one of these changes moves from a preset to custom.

@arouinfar what is the general desired behavior here?

Perhaps things stay paused because the velocity is zero? The PlayPauseButton should only temporarily flip to the paused state when dragging the balls. In this case, the PlayPauseButton should display pause after the ball is released because that was the state of the button before it the ball was grabbed.

This seems to be intentionally happening in this specific case:

 * In the 'Inelastic' screen, there are different 'presets' of Balls. When the user changes a the preset,
 * InelasticBallSystem will do the following:
 *   - Pause the sim.
 *   - Set the elapsed time to 0.
 *   - Set every Ball's position, mass, and velocity to the preset's BallStates, if the preset is not set to CUSTOM.
 *     Setting the preset to CUSTOM doesn't change any of the Balls.
 *   - If the user manipulates any of the two Balls, the preset is set to CUSTOM.

This seems to be happening because it's switching from a preset to the "custom" preset. Do we want to maintain the "when the user clicks on a different preset, including switching to custom, the sim always pauses"? So it would only be an auto-switch to custom which wouldn't pause?

I implemented my suggestion above, let me know how it seems.

Thanks for the explanation @jonathanolson. I think the behavior in master feels much more natural, so let's stick with that. Back to you for next steps.

This looks good in rc.2