Skip to content

Commit

Permalink
resolve jump direction and arrow cue display directions, see #148
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarlow12 committed Jan 11, 2019
1 parent 160cd70 commit f42ce55
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/faradays-law/view/MagnetNodeWithField.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ define( require => {
const faradaysLaw = require( 'FARADAYS_LAW/faradaysLaw' );
const FaradaysLawA11yStrings = require( 'FARADAYS_LAW/FaradaysLawA11yStrings' );
const FaradaysLawAlertManager = require( 'FARADAYS_LAW/faradays-law/view/FaradaysLawAlertManager' );
const FaradaysLawConstants = require( 'FARADAYS_LAW/faradays-law/FaradaysLawConstants' );
const FaradaysLawKeyboardDragListener = require( 'FARADAYS_LAW/faradays-law/view/FaradaysLawKeyboardDragListener' );
const FocusHighlightFromNode = require( 'SCENERY/accessibility/FocusHighlightFromNode' );
const JumpMagnitudeArrowNode = require( 'FARADAYS_LAW/faradays-law/view/JumpMagnitudeArrowNode' );
Expand All @@ -32,6 +33,10 @@ define( require => {
const barMagnetString = FaradaysLawA11yStrings.barMagnet.value;
const moveInFourDirectionsString = FaradaysLawA11yStrings.moveInFourDirections.value;

// constants
const HALF_MAGNET_WIDTH = FaradaysLawConstants.MAGNET_WIDTH / 2;
const HALF_MAGNET_HEIGHT = FaradaysLawConstants.MAGNET_HEIGHT / 2;

/**
* @param {FaradaysLawModel} model
* @param {Tandem} tandem
Expand Down Expand Up @@ -172,7 +177,8 @@ define( require => {

const magnitude = Number( domEvent.key );

if ( model.magnet.positionProperty.get().x <= ( model.bounds.maxX / 2 ) ) {
const dragBoundsMax = model.bounds.erodedXY( HALF_MAGNET_WIDTH, HALF_MAGNET_HEIGHT ).maxX;
if ( model.magnet.positionProperty.get().x < ( dragBoundsMax / 2 ) ) {
// point to right
rightJumpArrows.showCue( magnitude );
}
Expand Down

0 comments on commit f42ce55

Please sign in to comment.