phetsims / collision-lab

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

Investigate implementation of DragListeners of Balls #46

Closed brandonLi8 closed 4 years ago

brandonLi8 commented 4 years ago

Currently, BallNode creates a DragListener to allow the user to drag the ball. It does so with the Ball's positionProperty. However, in Ball.js, there is both

    // @public position of the ball for DragListener
    this.positionProperty = new Vector2Property( position );

and

    // @public (read-only)  momentumProperty - Property of the position of the ball in m
    this.positionDerivedProperty = new DerivedProperty( [ this.positionXProperty, this.positionYProperty ],
      ( positionX, positionY ) => new Vector2( positionX, positionY ) );

which seems redundant. This can be removed by implementing the DragListener in terms of view Properties, similar to how it's done in Vector Addition. This applies also to the Velocity DragListener as well.

For now, I'm going to go ahead and implement this change.

brandonLi8 commented 4 years ago

Changes implemented in the above commits. Closing.