Skip to content

Commit

Permalink
update the second alert, #184
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 5, 2019
1 parent a96902e commit 58fa463
Showing 1 changed file with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ) );

/**
*/
Expand Down Expand Up @@ -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
} );
}
Expand All @@ -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
*/
Expand Down

0 comments on commit 58fa463

Please sign in to comment.