phetsims / fractions-intro

"Fractions Intro" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
1 stars 3 forks source link

create an unlimited number of pieces from a filled cell with vertical bar representation #63

Closed veillette closed 7 years ago

veillette commented 7 years ago

In vertical bar representation, clicking on a cell (without dragging) generate a piece that flies to the bucket. However the filled cell does not get toggle to empty, allowing it to be clicked again.

coledu commented 7 years ago

What I have learn thus far about this bug:

A couple of line I have question thus far are:

Piece Drag Handler

if ( destinationCell.boundsProperty.value.containsPoint( piece.positionProperty.value ) ) {
            piece.cellToProperty.value = destinationCell;
          }
          else {
            piece.animateToAndFrom( piece.positionProperty.value, IntroConstants.BUCKET_POSITION );

options.startDrag();

Piece

        var animationTween = new TWEEN.Tween( location )
          .to( { x: finalPosition.x, y: finalPosition.y },
            distance * 5 )
          .easing( TWEEN.Easing.Cubic.InOut )
          .onUpdate( function() {
            self.positionProperty.value = new Vector2( location.x, location.y );
          } )
          .onComplete( function() {

            options.onComplete();

            // the piece can be removed from the pieces observable array
            self.reachedDestinationEmitter.emit();
          } );

        animationTween.start( phet.joist.elapsedTime );
      }
      else {

        // for cases where the distance is zero

        //  optional call back
        options.onComplete();

        // the piece can be removed from the pieces observable array
        self.reachedDestinationEmitter.emit();

So in conclusion this bug most likely have something to do with the isFIlledProperty of that cell. But I still do not understand have the centerPostion or if we drag it affect this bug.

coledu commented 7 years ago

The bug was an unnecessary if statement. Took it out and it fixed the bug. Assigning to @veillette for review.

veillette commented 7 years ago

This issue is stale since we used @jonathanolson prototype.