Skip to content

Commit

Permalink
begin mass position alerts using aria-valuetext instead of utterances…
Browse files Browse the repository at this point in the history
…, see #109
  • Loading branch information
mbarlow12 committed Dec 4, 2018
1 parent 87070ee commit b265783
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
18 changes: 9 additions & 9 deletions js/gravity-force-lab/view/GravityForceLabAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ define( require => {
}
} );

model.object1.valueProperty.lazyLink( ( value, oldValue ) => {
utteranceQueue.clear();
this.alertMassValueChanged( value, oldValue );
} );

model.object2.valueProperty.lazyLink( ( value, oldValue ) => {
utteranceQueue.clear();
this.alertMassValueChanged( value, oldValue );
} );
// model.object1.valueProperty.lazyLink( ( value, oldValue ) => {
// utteranceQueue.clear();
// this.alertMassValueChanged( value, oldValue );
// } );
//
// model.object2.valueProperty.lazyLink( ( value, oldValue ) => {
// utteranceQueue.clear();
// this.alertMassValueChanged( value, oldValue );
// } );
}

alertScientificNotation( displayInScientificNotation ) {
Expand Down
2 changes: 2 additions & 0 deletions js/gravity-force-lab/view/GravityForceLabScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ define( function( require ) {
model,
model.object1,
this.layoutBounds,
stringManager,
modelViewTransform, {
label: mass1AbbreviatedString,
otherObjectLabel: mass2AbbreviatedString,
Expand All @@ -110,6 +111,7 @@ define( function( require ) {
model,
model.object2,
this.layoutBounds,
stringManager,
modelViewTransform, {
label: mass2AbbreviatedString,
otherObjectLabel: mass1AbbreviatedString,
Expand Down
18 changes: 11 additions & 7 deletions js/gravity-force-lab/view/GravityForceLabStringManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ define( require => {
return StringUtils.fillIn( pattern, { massValue, size, relativeSize, otherObject } );
}

getSpherePositionAriaValueText( newPosition, oldPosition, objectNode ) {
return super.getSpherePositionAriaValueText( Util.toFixedNumber( newPosition + 4.8, 1 ), oldPosition, objectNode );
}

getMassValueChangedAlertText( newMass, oldMass ) {
let pattern = 'As mass {{massChange}}, vectors {{vectorChange}}.';
const objectIsGrowing = ( newMass - oldMass ) > 0;
Expand Down Expand Up @@ -279,25 +283,25 @@ define( require => {
getDistanceIndex( distance ) {
assert && assert( distance > 0, 'Distance between spheres should always be positive.' );

if ( distance >= 8.8 ) {
if ( distance >= 8.2 ) {
return 0;
}
if ( distance >= 7 ) {
if ( distance >= 6.7 ) {
return 1;
}
if ( distance >= 5 ) {
if ( distance >= 5.2 ) {
return 2;
}
if ( distance >= 3 ) {
if ( distance >= 3.7 ) {
return 3;
}
if ( distance >= 1 ) {
if ( distance >= 2.2 ) {
return 4;
}
if ( distance >= 0.6 ) {
if ( distance >= 0.9 ) {
return 5;
}
if ( distance < 0.6 ) {
if ( distance < 0.9 ) {
return 6;
}
throw new Error( 'Invalid distance value' );
Expand Down
22 changes: 15 additions & 7 deletions js/gravity-force-lab/view/MassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ define( function( require ) {
var GravityForceLabConstants = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabConstants' );
var inherit = require( 'PHET_CORE/inherit' );
var ISLCObjectNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCObjectNode' );
var ISLCStringManager = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCStringManager' );
// var ISLCStringManager = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCStringManager' );
var RadialGradient = require( 'SCENERY/util/RadialGradient' );
var Tandem = require( 'TANDEM/Tandem' );
var Util = require( 'DOT/Util' );
// var Util = require( 'DOT/Util' );

// constants
var ARROW_LABEL_COLOR_STRING = '#000';
Expand All @@ -32,7 +32,9 @@ define( function( require ) {
* @param {Object} [options]
* @constructor
*/
function MassNode( model, massModel, layoutBounds, modelViewTransform, options ) {
function MassNode( model, massModel, layoutBounds, stringManager, modelViewTransform, options ) {

var self = this;

options = _.extend( {
label: 'This Mass',
Expand All @@ -47,9 +49,17 @@ define( function( require ) {
tandem: Tandem.required,

// a11y
/*
the aria-valuetext will be of the form {{# meter mark}}, [ progress alert (closer/further) / region ], vector size
Patterns:
- {{position}} meter mark, {{progress}} {{otherObjectLabel}}, force vectors {{size}}
- {{position}} meter mark, {{progress}}, force vectors {{size}}
- {{position}} meter mark, {{region}} {{otherObject}}, force vectors {{size}}
- {{position}} meter mark, {{region}}, force vectors {{size}}
*/
createAriaValueText: function( formattedValue, previousValue ) {
formattedValue = Util.toFixedNumber( formattedValue + 4.8, 1 );
return ISLCStringManager.getPositionMeterMarkText( `${formattedValue} meter` );
return stringManager.getSpherePositionAriaValueText( formattedValue, previousValue, self );
// return ISLCStringManager.getPositionMeterMarkText( `${formattedValue} meter` );
}
}, options );

Expand All @@ -59,8 +69,6 @@ define( function( require ) {
this.objectModel = massModel;

ISLCObjectNode.call( this, model, massModel, layoutBounds, modelViewTransform, GravityForceLabConstants.PULL_FORCE_RANGE, options );

var self = this;
model.scientificNotationProperty.link( function( scientificNotation ) {
self.setReadoutsInScientificNotation( scientificNotation );
} );
Expand Down

0 comments on commit b265783

Please sign in to comment.