Skip to content

Commit

Permalink
faster animation, warp to drop location on animation, phetsims/build-…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Apr 25, 2017
1 parent 8d763e4 commit 8b9c448
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/model/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ define( function( require ) {
if ( !this.userControlledProperty.get() || this.isAccessibleControlled) {
var position = this.positionProperty.get();
var destination = this.destinationProperty.get();
var velocity = this.animationVelocityProperty.get();
var velocity = this.isAccessibleControlled ? this.animationVelocityProperty.get() * 4 : this.animationVelocityProperty.get();
var distanceToDestination = position.distance( destination );
if ( distanceToDestination > dt * velocity ) {
// This was broken up into individual steps in an attempt to solve an issue where complex vector operations
Expand Down
19 changes: 13 additions & 6 deletions js/view/ElectronShellView.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ define( function( require ) {
this.previouslyFocusedNode = this.centerOption;

// @private a11y - set the selectProperty when the arrow keys change the html select menu's value.
this.shellNucluesOptions = [ this.centerOption, this.innerRing, this.outerRing ];
this.shellNucleusOptions = [ this.centerOption, this.innerRing, this.outerRing ];

// // @private (a11y) - a map of drop locations for particles that are being moved into the atom with a keyboard
this.centerOption.shellNucleusHoverLocations = new Vector2( 10, 10 );
Expand All @@ -139,21 +139,23 @@ define( function( require ) {
this.addAccessibleInputListener( {
keydown: function( event ) {


if ( self.selectingShellNucleusOptions ) {
var isDownRight = event.keyCode === Input.KEY_DOWN_ARROW || event.keyCode === Input.KEY_RIGHT_ARROW;
var isUpLeft = event.keyCode === Input.KEY_UP_ARROW || event.keyCode === Input.KEY_LEFT_ARROW;

// if event was an arrow key
if ( isDownRight || isUpLeft ) {
if ( isDownRight ) {
self.currentOptionIndex = ( self.currentOptionIndex + 1 ) % self.shellNucluesOptions.length;
self.currentOptionIndex = ( self.currentOptionIndex + 1 ) % self.shellNucleusOptions.length;
}
else if ( isUpLeft ) {
self.currentOptionIndex = self.currentOptionIndex - 1;
if ( self.currentOptionIndex < 0 ) { self.currentOptionIndex = self.shellNucluesOptions.length - 1; }
if ( self.currentOptionIndex < 0 ) { self.currentOptionIndex = self.shellNucleusOptions.length - 1; }
}

var currentNode = self.shellNucluesOptions[ self.currentOptionIndex ];
var currentNode = self.shellNucleusOptions[ self.currentOptionIndex ];

currentNode.focus();

// Moving the particle to the current option
Expand Down Expand Up @@ -181,6 +183,10 @@ define( function( require ) {
if ( event.keyCode === Input.KEY_TAB || event.keyCode === Input.KEY_ESCAPE ) {
self.currentlySelectedBucketFront.bucket.addParticleFirstOpen( self.currentlyDraggedParticle, true );
}

var nucleusNode = self.shellNucleusOptions[ self.currentOptionIndex ];
self.currentlyDraggedParticle.positionProperty.set( nucleusNode.shellNucleusHoverLocations );

self.currentlyDraggedParticle.userControlledProperty.set( false );

// This is to help animate accessible drag
Expand Down Expand Up @@ -213,7 +219,7 @@ define( function( require ) {
self.selectingShellNucleusOptions = false;

// Not the node for the nucleus, let the out shells handle their own electron selection
var outerNode = self.shellNucluesOptions[ self.currentOptionIndex ];
var outerNode = self.shellNucleusOptions[ self.currentOptionIndex ];

outerNode.chooseElectron( self.currentlyDraggedParticle, self.currentlySelectedBucketFront );
}
Expand Down Expand Up @@ -326,6 +332,7 @@ define( function( require ) {
if ( event.keyCode === Input.KEY_TAB || event.keyCode === Input.KEY_ESCAPE ) {
self.activeBucketFront.bucket.addParticleFirstOpen( self.activeParticle, true );
}
self.activeParticle.positionProperty.set( electronShellPositions[ self.currentOptionIndex ].position );
self.activeParticle.userControlledProperty.set( false );

self.electronPlacementNodes.forEach( function( childCircle ) {
Expand Down Expand Up @@ -450,7 +457,7 @@ define( function( require ) {

// @public (a11y)
getCurrentParticleHoverLocation: function() {
return this.shellNucluesOptions[ this.currentOptionIndex ].shellNucleusHoverLocations;
return this.shellNucleusOptions[ this.currentOptionIndex ].shellNucleusHoverLocations;
}
} );

Expand Down

0 comments on commit 8b9c448

Please sign in to comment.