Skip to content

Commit

Permalink
brief alert for distance arrow, see #196
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Mar 18, 2020
1 parent 563aa94 commit 4a2111a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions js/GFLBA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ const GFLBA11yStrings = {
verboseDistanceArrowDescription: {
value: 'Centers of spheres, {{distance}} kilometers apart.'
},
briefDistanceArrowDescription: {
value: 'Centers {{distance}} kilometers apart.'
},

// mass spheres
redColor: {
Expand Down
12 changes: 9 additions & 3 deletions js/view/DistanceArrowNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const distanceUnitsPatternString = gravityForceLabBasicsStrings.distanceUnitsPat

// a11y strings
const verboseDistanceArrowDescriptionString = GFLBA11yStrings.verboseDistanceArrowDescription.value;
const briefDistanceArrowDescriptionString = GFLBA11yStrings.briefDistanceArrowDescription.value;

// constants
const HEAD_WIDTH = 6;
Expand Down Expand Up @@ -72,9 +73,14 @@ class DistanceArrowNode extends Node {
options.shapeHitDetector.addNode( this );
options.shapeHitDetector.hitShapeEmitter.addListener( hitTarget => {
if ( hitTarget === this ) {
webSpeaker.speak( StringUtils.fillIn( verboseDistanceArrowDescriptionString, {
distance: model.separationProperty.get() / 1000 // m to km
} ) );
if ( webSpeaker.exploreModeProperty.get() ) {
const verboseMode = webSpeaker.exploreModeVerbosityProperty.get() === webSpeaker.Verbosity.VERBOSE;
const patternString = verboseMode ? verboseDistanceArrowDescriptionString : briefDistanceArrowDescriptionString;

webSpeaker.speak( StringUtils.fillIn( patternString, {
distance: model.separationProperty.get() / 1000 // m to km
} ) );
}
}
} );
}
Expand Down

0 comments on commit 4a2111a

Please sign in to comment.