From 58fa463043c436ccb13df10e822a2fe832d0e191 Mon Sep 17 00:00:00 2001 From: zepumph Date: Tue, 5 Nov 2019 10:57:29 -0900 Subject: [PATCH] update the second alert, https://github.com/phetsims/gravity-force-lab/issues/184 --- .../GravityForceLabRulerDescriber.js | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js b/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js index 1885cb84..8c9f316c 100644 --- a/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js +++ b/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js @@ -11,6 +11,7 @@ define( require => { // modules const gravityForceLab = require( 'GRAVITY_FORCE_LAB/gravityForceLab' ); const GravityForceLabA11yStrings = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabA11yStrings' ); + const Range = require( 'DOT/Range' ); const StringUtils = require( 'PHETCOMMON/util/StringUtils' ); // a11y strings @@ -40,6 +41,9 @@ define( require => { behindMassControlsString ]; + // These regions are treated differently, as they are in the range that suggests pedagogically relevant interaction. + const TARGET_REGIONS_RANGE = new Range( RULER_VERTICAL_REGIONS.indexOf( justAboveCentersString ), + RULER_VERTICAL_REGIONS.indexOf( justBelowCentersString ) ); /** */ @@ -79,9 +83,17 @@ define( require => { if ( phet.joist.sim.supportsGestureA11y ) { return gestureHintString; } + let playHint = jumpKeyboardHintString; + const regionIndex = this.getVerticalRegionIndex(); + + // if on the second grab, the user still isn't in a measurable location, then repeat the first hint to jump to the + // center. + if ( this.grabbedCount === 2 && TARGET_REGIONS_RANGE.contains( regionIndex ) ) { + playHint = moveKeyboardHintString; + } return StringUtils.fillIn( hintPatternString, { - playHint: this.grabbedCount === 1 ? jumpKeyboardHintString : moveKeyboardHintString, + playHint: playHint, releaseHint: keyboardReleaseHintString } ); } @@ -102,20 +114,25 @@ define( require => { /** * @private - * @returns {*} + * @returns {number} - integer index of the region */ - getCurrentVerticalRegion() { + getVerticalRegionIndex() { const viewY = this.modelViewTransform.modelToViewY( this.rulerPositionProperty.value.y ); - console.log( viewY ); for ( let i = 0; i < this.viewYPositions.length; i++ ) { if ( viewY <= this.viewYPositions[ i ] ) { - console.log( RULER_VERTICAL_REGIONS[ i ] ); - return RULER_VERTICAL_REGIONS[ i ]; + return i; } - } } + /** + * @private + * @returns {*} + */ + getCurrentVerticalRegion() { + return RULER_VERTICAL_REGIONS[ this.getVerticalRegionIndex() ]; + } + /** * @public */