Skip to content

Commit

Permalink
guard against particle calls in empty bucket, #150
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 31, 2017
1 parent dbbd291 commit 87a337c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js/common/view/AtomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ define( function( require ) {

bucketFront.addAccessibleInputListener( {
click: function() {
// get the closest particle to nucleus
var nearestParticle = bucket.extractClosestParticle( new Vector2( 0, 0 ) );
if ( bucket.getParticleList().length > 0 ) {

// move it to the first drop location (offset by a little to indicate it is still being placed)
model.moveParticleToDropLocation( nearestParticle, model.particleAtom.positionProperty.get() );
// get the closest particle to nucleus
var nearestParticle = bucket.extractClosestParticle( new Vector2( 0, 0 ) );

// focus the atom for placement of particles
atomNode.electronShell.handleAccessibleDrag( nearestParticle, bucketFront );
// move it to the first drop location (offset by a little to indicate it is still being placed)
model.moveParticleToDropLocation( nearestParticle, model.particleAtom.positionProperty.get() );

// focus the atom for placement of particles
atomNode.electronShell.handleAccessibleDrag( nearestParticle, bucketFront );
}
}
} );
} );
Expand Down

0 comments on commit 87a337c

Please sign in to comment.