Skip to content

Commit

Permalink
removed comment, slider alerts draft see #180
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarlow12 committed May 18, 2018
1 parent e80e0c1 commit 507e8c6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
54 changes: 52 additions & 2 deletions js/photon-absorption/view/EmissionRateControlSliderNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ define( function( require ) {
var Range = require( 'DOT/Range' );
var Rectangle = require( 'SCENERY/nodes/Rectangle' );
var Shape = require( 'KITE/Shape' );
// var StringUtils = require( 'PHETCOMMON/util/StringUtils' );
var StringUtils = require( 'PHETCOMMON/util/StringUtils' );
var utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );
var WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' );

// constants
Expand Down Expand Up @@ -86,16 +87,65 @@ define( function( require ) {
var parentBounds = sliderThumb.localToParentBounds( sliderBounds );
this.emissionRateControlSlider.focusHighlight = new FocusHighlightPath( Shape.bounds( parentBounds ) );

// a11y
// a11y// takes a given frequency and returns the proper string for its associated rate
function mapFrequencyToString( freq ) {
// debugger;
// can be moved to constants file
var sliderRangeMap = [
{
range: {
contains: function ( val ) {
return val > 0 && val < 0.3;
}
},
text: 'slow'
},
{
range: {
contains: function( val ) {
return val >= 0.3 && val < 0.7;
}
},
text: 'moderate'
},
{
range: {
contains: function( val ) {
return val >= 0.7 && val <= 1;
}
},
text: 'fast'
}
];

for ( var i = sliderRangeMap.length - 1; i >= 0; i-- ) {
if ( sliderRangeMap[ i ].range.contains ( freq ) ) {
return sliderRangeMap[ i ].text;
}
}
}
this.emissionRateControlSlider.addAccessibleInputListener( {
focus: function() {
sliderThumb.backgroundRectangle.visible = true;
},
blur: function() {
sliderThumb.backgroundRectangle.visible = false;
},
keyup: function() {
var frequencyText = mapFrequencyToString( model.emissionFrequencyProperty.get() );
var wavelengthText = WavelengthConstants.getLightSourceName( model.photonWavelengthProperty.get() );

utteranceQueue.addToBack( StringUtils.fillIn(
'{{wavelengthText}} photon rate, {{frequencyText}}',
{ wavelengthText: wavelengthText, frequencyText: frequencyText }
) );
}
} );

// a11y alerts for the slider
// model.emissionFrequencyProperty.lazyLink( function( frequency ) {
// } );

// width of the background rectangle is larger than the slider to accentuate the thumb.
var backgroundOffset = 4;
this.backgroundRect = new Rectangle(
Expand Down
1 change: 0 additions & 1 deletion js/photon-absorption/view/MoleculeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ define( function( require ) {
var MoleculesAndLightA11yStrings = require( 'MOLECULES_AND_LIGHT/common/MoleculesAndLightA11yStrings' );
var Node = require( 'SCENERY/nodes/Node' );
var StringUtils = require( 'PHETCOMMON/util/StringUtils' );
// var Utterance = require( 'SCENERY_PHET/accessibility/Utterance' );
var utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );
var NO = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/molecules/NO' );
var CO = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/molecules/CO' );
Expand Down

0 comments on commit 507e8c6

Please sign in to comment.