diff --git a/js/ISLCA11yStrings.js b/js/ISLCA11yStrings.js index 00f83b9..4b370ac 100644 --- a/js/ISLCA11yStrings.js +++ b/js/ISLCA11yStrings.js @@ -7,14 +7,15 @@ define( require => { const inverseSquareLawCommon = require( 'INVERSE_SQUARE_LAW_COMMON/inverseSquareLawCommon' ); const ISLCA11yStrings = { + // TODO: replace instances of {{objectValueUnits}} or {{valueAndUnits}} to {{value}} {{units}} /*************************** * Summary Pattern Strings * ***************************/ - vectorSizePattern: { + summaryVectorSizePattern: { value: 'Force vectors are {{size}}.' }, - vectorSizeValueUnitsPattern: { + summaryVectorSizeValueUnitsPattern: { value: 'Force vectors are {{size}} at {{objectValueUnits}}.' }, robotPullSummaryPattern: { @@ -90,15 +91,24 @@ define( require => { /************************ * Force vector strings * ************************/ - forceVectorsSize: { + forceVectorSizePattern: { value: 'Force vectors {{size}}.' }, - vectorAlertNoValuePattern: { + vectorSizeForcesValuePattern: { + value: 'Vectors {{size}}, forces {{valueAndUnits}}.' + }, + vectorSizePattern: { value: 'Vectors {{changeOrSize}}.' }, - vectorAlertWithValuePattern: { + vectorSizeForcesNowValuePattern: { value: 'Vectors {{changeOrSize}}, forces now {{valueAndUnits}}.' }, + getBigger: { + value: 'get bigger' + }, + getSmaller: { + value: 'get smaller' + }, /********************** * Qualitative Values * diff --git a/js/view/ISLCObjectNode.js b/js/view/ISLCObjectNode.js index c685553..476ebbb 100644 --- a/js/view/ISLCObjectNode.js +++ b/js/view/ISLCObjectNode.js @@ -33,6 +33,8 @@ define( function( require ) { var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' ); var Tandem = require( 'TANDEM/Tandem' ); var Util = require( 'DOT/Util' ); + var Utterance = require( 'SCENERY_PHET/accessibility/Utterance' ); + var utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' ); // phetio var BooleanProperty = require( 'AXON/BooleanProperty' ); @@ -85,7 +87,7 @@ define( function( require ) { * @param {Object} options * @constructor */ - function ISLCObjectNode( model, object, layoutBounds, modelViewTransform, pullForceRange, options ) { + function ISLCObjectNode( model, object, layoutBounds, stringManager, modelViewTransform, pullForceRange, options ) { var self = this; @@ -294,7 +296,11 @@ define( function( require ) { this.redrawForce(); + // a11y - for experimenting with default step sizes. Ignore if not explicitly set var defaultStepSize = QueryStringMachine.containsKey( 'stepSize' ) ? ISLCQueryParameters.stepSize : options.snapToNearest * 2; + + var currentPosition = object.positionProperty.get(); + var currentForce = model.forceProperty.get(); var accessibleSliderOptions = { keyboardStep: defaultStepSize, shiftKeyboardStep: options.snapToNearest, @@ -306,10 +312,34 @@ define( function( require ) { }, startDrag: function() { object.isDragging = true; + currentPosition = object.positionProperty.get(); + currentForce = model.forceProperty.get(); }, endDrag: function() { + var newPosition = object.positionProperty.get(); + var newForce = model.forceProperty.get(); + var forceGrowing = ( newForce - currentForce ) > 0; + var positionChanged = newPosition - currentPosition; object.isDragging = false; self.redrawForce(); + + // TODO: consider implementing with alertManager + // alertManager.positionSliderAlert( positionChanged ); + if ( positionChanged ) { + // alert force vectors changed + // TODO: consider setting forceGrowing in ISLCStringManager + utteranceQueue.addToBack( new Utterance( { + alert: stringManager.getForceVectorsChangedAlertText( forceGrowing ), + uniqueGroupId: 'forceVectorChanged' + } ) ); + } + else { + // alert state of force vectors + utteranceQueue.addToBack( new Utterance( { + alert: stringManager.getForceVectorStateAlertText(), + uniqueGroupId: 'forceVectorState' + } ) ); + } }, createAriaValueText: options.createAriaValueText }; diff --git a/js/view/ISLCStringManager.js b/js/view/ISLCStringManager.js index 34917f8..65dd58c 100644 --- a/js/view/ISLCStringManager.js +++ b/js/view/ISLCStringManager.js @@ -18,23 +18,24 @@ define( require => { const unitsMetersString = require( 'string!INVERSE_SQUARE_LAW_COMMON/units.meters' ); const unitsNewtonsString = require( 'string!INVERSE_SQUARE_LAW_COMMON/units.newtons' ); - const vectorSizePatternString = ISLCA11yStrings.vectorSizePattern.value; - const vectorSizeValueUnitsPatternString = ISLCA11yStrings.vectorSizeValueUnitsPattern.value; + const summaryVectorSizePatternString = ISLCA11yStrings.summaryVectorSizePattern.value; + const summaryVectorSizeValueUnitsPatternString = ISLCA11yStrings.summaryVectorSizeValueUnitsPattern.value; const summaryInteractionHintPatternString = ISLCA11yStrings.summaryInteractionHintPattern.value; const distanceAndValueSummaryPatternString = ISLCA11yStrings.distanceAndValueSummaryPattern.value; const robotPullSummaryPatternString = ISLCA11yStrings.robotPullSummaryPattern.value; const robotPushSummaryPatternString = ISLCA11yStrings.robotPushSummaryPattern.value; + const vectorSizePatternString = ISLCA11yStrings.vectorSizePattern.value; + const forceVectorSizePatternString = ISLCA11yStrings.forceVectorSizePattern.value; + const vectorSizeForcesValuePatternString = ISLCA11yStrings.vectorSizeForcesValuePattern.value; + const vectorSizeForcesNowValuePatternString = ISLCA11yStrings.vectorSizeForcesNowValuePattern.value; + // sphere strings - // const spherePositionHelpTextString = ISLCA11yStrings.spherePositionHelpText.value; const forceVectorMagnitudePatternString = ISLCA11yStrings.forceVectorMagnitudePattern.value; const forceAndVectorPatternString = ISLCA11yStrings.forceAndVectorPattern.value; const positionMeterMarkPatternString = ISLCA11yStrings.positionMeterMarkPattern.value; const objectLabelPositionPatternString = ISLCA11yStrings.objectLabelPositionPattern.value; - // const spherePositionProgressObjectPatternString = ISLCA11yStrings.spherePositionProgressObjectPattern.value; - // const spherePositionProgressPatternString = ISLCA11yStrings.spherePositionProgressPattern.value; const spherePositionRegionObjectPatternString = ISLCA11yStrings.spherePositionRegionObjectPattern.value; - // const spherePositionRegionPatternString = ISLCA11yStrings.spherePositionRegionPattern.value; /* new from 12/11/18 */ const positionDistanceFromOtherObjectPatternString = ISLCA11yStrings.positionDistanceFromOtherObjectPattern.value; @@ -42,6 +43,9 @@ define( require => { const distanceFromOtherObjectPatternString = ISLCA11yStrings.distanceFromOtherObjectPattern.value; const lastStopDistanceFromOtherObjectPatternString = ISLCA11yStrings.lastStopDistanceFromOtherObjectPattern.value; + const getBiggerString = ISLCA11yStrings.getBigger.value; + const getSmallerString = ISLCA11yStrings.getSmaller.value; + const tinyString = ISLCA11yStrings.tiny.value; const verySmallString = ISLCA11yStrings.verySmall.value; const smallString = ISLCA11yStrings.small.value; @@ -221,8 +225,8 @@ define( require => { getForceVectorsSummaryText() { const fillObject = {}; const pattern = this.model.forceValuesProperty.get() ? - vectorSizeValueUnitsPatternString : - vectorSizePatternString; + summaryVectorSizeValueUnitsPatternString : + summaryVectorSizePatternString; fillObject.size = this.getForceVectorSize(); @@ -253,6 +257,34 @@ define( require => { return StringUtils.fillIn( pattern, { effort } ); } + getForceVectorsChangedAlertText( vectorsGrowing ) { + const changeOrSize = vectorsGrowing ? getBiggerString : getSmallerString; + const valueAndUnits = this.getForceValueText(); + const fillObject = { changeOrSize }; + + let pattern = vectorSizePatternString; + + if ( this.model.forceValuesProperty.get() ) { + pattern = vectorSizeForcesNowValuePatternString; + fillObject.valueAndUnits = valueAndUnits; + } + + return StringUtils.fillIn( pattern, fillObject ); + } + + getForceVectorStateAlertText() { + const size = this.getForceVectorSize(); + const fillObject = { size }; + let pattern = forceVectorSizePatternString; + + if ( this.model.forceValuesProperty.get() ) { + pattern = vectorSizeForcesValuePatternString; + fillObject.valueAndUnits = this.getForceValueText(); + } + + return StringUtils.fillIn( pattern, fillObject ); + } + // TODO: string usage getPositionFocusAlertText() { const pattern = 'Force vectors {{size}}';