Skip to content

Commit

Permalink
implement particle placement highlighting using select menu, #150
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 30, 2017
1 parent bb6c464 commit 16bdec2
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions js/common/view/AtomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ define( function( require ) {
var Vector2 = require( 'DOT/Vector2' );
var VerticalCheckBoxGroup = require( 'SUN/VerticalCheckBoxGroup' );
var BooleanProperty = require( 'AXON/BooleanProperty' );
var Circle = require( 'SCENERY/nodes/Circle' );
var Property = require( 'AXON/Property' );

// strings
var elementString = require( 'string!BUILD_AN_ATOM/element' );
Expand Down Expand Up @@ -115,23 +113,6 @@ define( function( require ) {
var electronLayer = new Node( { layerSplit: true, tandem: tandem.createTandem( 'electronLayer' ) } );
nucleonElectronLayer.addChild( electronLayer );

// a11y - to focus around the actual nucleus, will change in size when the particles in the nucleus change
var nucleusFocusHighlight = new Circle( model.particleAtom.nucleusRadius, {
lineWidth: 2,
stroke: 'red',
center: modelViewTransform.modelToViewPosition( model.particleAtom.positionProperty.get() ),
} );
this.addChild( nucleusFocusHighlight );

// whenever a nucleon is added or removed, change the highlight radius
Property.multilink( [ model.particleAtom.protonCountProperty, model.particleAtom.neutronCountProperty ], function( protonCount, neutronCount ) {

// TODO: Is there another way to link to the changing nucleus configuration
model.particleAtom.reconfigureNucleus();
var radiusOffset = model.particleAtom.nucleusRadius === 0 ? 0 : 4;
nucleusFocusHighlight.radius = model.particleAtom.nucleusRadius + radiusOffset;
} );

// Add the nucleon particle views.
var nucleonsGroupTandem = tandem.createGroupTandem( 'nucleons' );
var electronsGroupTandem = tandem.createGroupTandem( 'electrons' );
Expand Down Expand Up @@ -216,7 +197,7 @@ define( function( require ) {
var nearestParticle = bucket.extractClosestParticle( new Vector2( 0, 0 ) );

// move it to the first drop location (offset by a little to indicate it is still being placed)
model.moveParticleToDropLocation( nearestParticle, model.accessibleDropLocations.NUCLEUS.minusXY( 5, -5 ) );
model.moveParticleToDropLocation( nearestParticle, model.accessibleDropLocations.NUCLEUS.minusXY( 50, -50 ) );
}
} );
} );
Expand Down

0 comments on commit 16bdec2

Please sign in to comment.