diff --git a/js/friction-main.js b/js/friction-main.js index bf1d2158..c42c1516 100644 --- a/js/friction-main.js +++ b/js/friction-main.js @@ -28,12 +28,12 @@ define( function( require ) { const frictionTitleString = require( 'string!FRICTION/friction.title' ); // constants - let LAYOUT_BOUNDS = new Bounds2( 0, 0, 768, 504 ); + const LAYOUT_BOUNDS = new Bounds2( 0, 0, 768, 504 ); SimLauncher.launch( function() { - let keyboardHelpContent = new FrictionKeyboardHelpContentPanel(); - let simOptions = { + const keyboardHelpContent = new FrictionKeyboardHelpContentPanel(); + const simOptions = { credits: { leadDesign: 'Michael Dubson, Noah Podolefsky', softwareDevelopment: 'Michael Dubson, John Blanco, Jonathan Olson', @@ -50,7 +50,7 @@ define( function( require ) { }; // Create and start the sim - let screenTandem = Tandem.rootTandem.createTandem( 'frictionScreen' ); + const screenTandem = Tandem.rootTandem.createTandem( 'frictionScreen' ); new Sim( frictionTitleString, [ new Screen( function() { return new FrictionModel( LAYOUT_BOUNDS.width, LAYOUT_BOUNDS.height, screenTandem.createTandem( 'model' ) ); diff --git a/js/friction/FrictionA11yStrings.js b/js/friction/FrictionA11yStrings.js index 3dad1c22..3d39889e 100644 --- a/js/friction/FrictionA11yStrings.js +++ b/js/friction/FrictionA11yStrings.js @@ -248,7 +248,7 @@ define( function( require ) { // TODO: This seems it should be factored out, see https://github.com/phetsims/tasks/issues/917 if ( phet.chipper.queryParameters.stringTest === 'xss' ) { - for ( let key in FrictionA11yStrings ) { + for ( const key in FrictionA11yStrings ) { FrictionA11yStrings[ key ].value += ''; } } diff --git a/js/friction/FrictionConstants.js b/js/friction/FrictionConstants.js index b7efeb01..33a6c527 100644 --- a/js/friction/FrictionConstants.js +++ b/js/friction/FrictionConstants.js @@ -28,7 +28,7 @@ define( function( require ) { const atWarmString = FrictionA11yStrings.atWarm.value; const atCoolString = FrictionA11yStrings.atCool.value; - let FrictionConstants = { + const FrictionConstants = { TOP_BOOK_COLOR_MACRO: new Color( 'rgb(125,226,249)' ), // color of the macroscopic view of the book TOP_BOOK_COLOR: new Color( 'rgb(125,226,249)' ), // color for the book in the magnified view TOP_BOOK_ATOMS_COLOR: new Color( 'rgb( 0, 255, 255 )' ), // color for the atoms in the magnified view diff --git a/js/friction/model/Atom.js b/js/friction/model/Atom.js index 06e82c50..4e68961c 100644 --- a/js/friction/model/Atom.js +++ b/js/friction/model/Atom.js @@ -17,7 +17,7 @@ define( function( require ) { const Vector2 = require( 'DOT/Vector2' ); // constants - let EVAPORATED_SPEED = 400; // speed that particles travel during evaporation, in model units per second + const EVAPORATED_SPEED = 400; // speed that particles travel during evaporation, in model units per second /** * @param {Vector2} initialPosition @@ -27,7 +27,7 @@ define( function( require ) { * @constructor */ function Atom( initialPosition, model, isTopAtom, tandem ) { - let self = this; + const self = this; // @private {Vector2} - initial position, used during resets this.initialPosition = initialPosition; @@ -55,8 +55,8 @@ define( function( require ) { // move the atom's center position as the top book moves model.topBookPositionProperty.lazyLink( function( newPosition, oldPosition ) { if ( !self.isEvaporated ) { - let deltaX = newPosition.x - oldPosition.x; - let deltaY = newPosition.y - oldPosition.y; + const deltaX = newPosition.x - oldPosition.x; + const deltaY = newPosition.y - oldPosition.y; self.centerPosition.setXY( self.centerPosition.x + deltaX, self.centerPosition.y + deltaY ); } } ); @@ -76,8 +76,8 @@ define( function( require ) { assert && assert( !this.isEvaporated, 'Atom was already evaporated' ); this.isEvaporated = true; - let evaporationDestinationX = this.model.width * ( phet.joist.random.nextBoolean() ? 1 : -1 ); - let evaporationDestinationY = this.positionProperty.get().y - + const evaporationDestinationX = this.model.width * ( phet.joist.random.nextBoolean() ? 1 : -1 ); + const evaporationDestinationY = this.positionProperty.get().y - this.model.distanceBetweenBooksProperty.get() * phet.joist.random.nextDouble(); this.evaporationVelocity.setXY( @@ -103,7 +103,7 @@ define( function( require ) { step: function( dt ) { // update the atom's position based on vibration and center position - let newPosition = new Vector2( + const newPosition = new Vector2( this.centerPosition.x + this.model.amplitudeProperty.get() * ( phet.joist.random.nextDouble() - 0.5 ), this.centerPosition.y + this.model.amplitudeProperty.get() * ( phet.joist.random.nextDouble() - 0.5 ) ); diff --git a/js/friction/model/FrictionModel.js b/js/friction/model/FrictionModel.js index c9598a8e..f4410ab3 100644 --- a/js/friction/model/FrictionModel.js +++ b/js/friction/model/FrictionModel.js @@ -165,7 +165,7 @@ define( function( require ) { * @constructor */ function FrictionModel( width, height, tandem ) { - let self = this; + const self = this; // @public (read-only) {Number} - the width for the model in model coordinates this.width = width; @@ -223,7 +223,7 @@ define( function( require ) { this.bookDraggingScaleFactor = 0.025; // group tandem for creating the atoms - let atomGroupTandem = tandem.createGroupTandem( 'atoms' ); + const atomGroupTandem = tandem.createGroupTandem( 'atoms' ); // @public (read-only) {Atom[]} - array of atoms that are visible to the user in the magnifier window this.atoms = []; @@ -270,8 +270,8 @@ define( function( require ) { oldPosition = oldPosition || Vector2.ZERO; self.distanceBetweenBooksProperty.set( self.distanceBetweenBooksProperty.get() - ( newPosition.minus( oldPosition ) ).y ); if ( self.contactProperty.get() ) { - let dx = Math.abs( newPosition.x - oldPosition.x ); - let newValue = self.amplitudeProperty.get() + dx * HEATING_MULTIPLIER; + const dx = Math.abs( newPosition.x - oldPosition.x ); + const newValue = self.amplitudeProperty.get() + dx * HEATING_MULTIPLIER; self.amplitudeProperty.set( Math.min( newValue, MAGNIFIED_ATOMS_INFO.vibrationAmplitude.max ) ); } } ); @@ -288,13 +288,13 @@ define( function( require ) { function addAtomRow( frictionModel, layerDescription, rowStartXPos, rowYPos, isTopAtom, atomGroupTandem ) { let canEvaporate; - let evaporableAtomsRow = []; + const evaporableAtomsRow = []; for ( let i = 0; i < layerDescription.length; i++ ) { - let offset = layerDescription[ i ].offset || 0; + const offset = layerDescription[ i ].offset || 0; canEvaporate = layerDescription[ i ].canEvaporate || false; for ( let n = 0; n < layerDescription[ i ].num; n++ ) { - let atom = new Atom( + const atom = new Atom( new Vector2( rowStartXPos + ( offset + n ) * MAGNIFIED_ATOMS_INFO.distanceX, rowYPos ), frictionModel, isTopAtom, @@ -400,13 +400,13 @@ define( function( require ) { if ( this.atomRowsToEvaporateProperty.get() > 0 ) { // determine whether the current row is fully evaporated and, if so, move to the next row - let currentRowOfEvaporableAtoms = this.evaporableAtomsByRow[ this.atomRowsToEvaporateProperty.get() - 1 ]; + const currentRowOfEvaporableAtoms = this.evaporableAtomsByRow[ this.atomRowsToEvaporateProperty.get() - 1 ]; // if there are any rows of evaporable atoms left, evaporate one if ( currentRowOfEvaporableAtoms.length > 0 ) { // make a list of all atoms in this row that have not yet evaporated - let unevaporatedAtoms = currentRowOfEvaporableAtoms.filter( function( atom ) { + const unevaporatedAtoms = currentRowOfEvaporableAtoms.filter( function( atom ) { return !atom.isEvaporated; } ); @@ -416,7 +416,7 @@ define( function( require ) { ); // randomly choose an unevaporated atom and evaporate it - let atomToEvaporate = phet.joist.random.sample( unevaporatedAtoms ); + const atomToEvaporate = phet.joist.random.sample( unevaporatedAtoms ); atomToEvaporate.evaporate(); this.evaporationEmitter.emit(); diff --git a/js/friction/view/BookRubSoundGenerator.js b/js/friction/view/BookRubSoundGenerator.js index cd7ee838..4b44b0e4 100644 --- a/js/friction/view/BookRubSoundGenerator.js +++ b/js/friction/view/BookRubSoundGenerator.js @@ -84,7 +84,7 @@ define( function( require ) { if ( contact && Math.abs( topBookXVelocity ) > 0 && !rubSoundLockedOut ) { // set the output level based on the velocity of the book - let noiseAmplitude = options.maxOutputLevel * Math.min( Math.pow( Math.abs( topBookXVelocity ), 0.25 ), 1 ); + const noiseAmplitude = options.maxOutputLevel * Math.min( Math.pow( Math.abs( topBookXVelocity ), 0.25 ), 1 ); this.setOutputLevel( noiseAmplitude, 0.05 ); } else { diff --git a/js/friction/view/FrictionA11yGrabDragNode.js b/js/friction/view/FrictionA11yGrabDragNode.js index abe94a06..e10fa367 100644 --- a/js/friction/view/FrictionA11yGrabDragNode.js +++ b/js/friction/view/FrictionA11yGrabDragNode.js @@ -52,7 +52,7 @@ define( function( require ) { }, options ); // Keep track of the passed in grab listener, to add to it below - let oldGrab = options.onGrab; + const oldGrab = options.onGrab; // Wrap the onGrab option in default functionality for al of the type in Friction options.onGrab = () => { @@ -60,7 +60,7 @@ define( function( require ) { oldGrab && oldGrab(); - let alerts = model.contactProperty.get() ? touchingAlerts : notTouchingAlerts; + const alerts = model.contactProperty.get() ? touchingAlerts : notTouchingAlerts; let alert = alerts.initial; if ( this.successfullyInteracted ) { diff --git a/js/friction/view/FrictionKeyboardDragListener.js b/js/friction/view/FrictionKeyboardDragListener.js index 9ce8d1db..f0f7791d 100644 --- a/js/friction/view/FrictionKeyboardDragListener.js +++ b/js/friction/view/FrictionKeyboardDragListener.js @@ -38,7 +38,7 @@ define( function( require ) { TemperatureDecreasingDescriber.getDescriber().startDrag(); }, drag: () => { - let newValue = model.topBookPositionProperty.get(); + const newValue = model.topBookPositionProperty.get(); model.move( new Vector2( newValue.x - oldPositionValue.x, newValue.y - oldPositionValue.y ) ); // update the oldPositionValue for the next onDrag diff --git a/js/friction/view/FrictionKeyboardHelpContentPanel.js b/js/friction/view/FrictionKeyboardHelpContentPanel.js index 7de5eec2..03e95a66 100644 --- a/js/friction/view/FrictionKeyboardHelpContentPanel.js +++ b/js/friction/view/FrictionKeyboardHelpContentPanel.js @@ -28,11 +28,11 @@ define( function( require ) { const moveInSmallerStepsString = require( 'string!FRICTION/moveInSmallerSteps' ); // a11y strings - let moveBookWithString = FrictionA11yStrings.moveBookWith.value; - let moveInSmallerStepsWithString = FrictionA11yStrings.moveInSmallerStepsWith.value; + const moveBookWithString = FrictionA11yStrings.moveBookWith.value; + const moveInSmallerStepsWithString = FrictionA11yStrings.moveInSmallerStepsWith.value; // constants - let DEFAULT_LABEL_OPTIONS = { + const DEFAULT_LABEL_OPTIONS = { font: HelpContent.DEFAULT_LABEL_FONT, maxWidth: HelpContent.DEFAULT_TEXT_MAX_WIDTH, lineWrap: HelpContent.DEFAULT_TEXT_MAX_WIDTH - 10 // extra value necessary for proper wrapping, see https://github.com/phetsims/friction/issues/138#issuecomment-442347693 @@ -43,13 +43,13 @@ define( function( require ) { */ function FrictionKeyboardHelpContentPanel() { - let grabReleaseHelpContent = HelpContent.getGrabReleaseHelpContent( bookTitleString, bookLabelString ); - let moveBookHelpContent = new MoveBookHelpNode(); - let generalNavigationHelpContent = new GeneralNavigationHelpContent(); + const grabReleaseHelpContent = HelpContent.getGrabReleaseHelpContent( bookTitleString, bookLabelString ); + const moveBookHelpContent = new MoveBookHelpNode(); + const generalNavigationHelpContent = new GeneralNavigationHelpContent(); HelpContent.alignHelpContentIcons( [ grabReleaseHelpContent, moveBookHelpContent ] ); - let content = new HBox( { + const content = new HBox( { children: [ new VBox( { children: [ grabReleaseHelpContent, moveBookHelpContent ], spacing: 10, align: 'left' } ), generalNavigationHelpContent @@ -80,15 +80,15 @@ define( function( require ) { }, options ); // BookNode row - let moveBookText = new RichText( moveBookString, DEFAULT_LABEL_OPTIONS ); - let moveBookIcon = HelpContent.arrowOrWasdKeysRowIcon(); - let moveBookRow = HelpContent.labelWithIcon( moveBookText, moveBookIcon, moveBookWithString ); + const moveBookText = new RichText( moveBookString, DEFAULT_LABEL_OPTIONS ); + const moveBookIcon = HelpContent.arrowOrWasdKeysRowIcon(); + const moveBookRow = HelpContent.labelWithIcon( moveBookText, moveBookIcon, moveBookWithString ); // BookNode in smaller steps row - let moveInSmallerStepsText = new RichText( moveInSmallerStepsString, DEFAULT_LABEL_OPTIONS ); - let shiftPlusArrowKeys = HelpContent.shiftPlusIcon( HelpContent.arrowKeysRowIcon() ); - let shiftPlusWASDKeys = HelpContent.shiftPlusIcon( HelpContent.wasdRowIcon() ); - let row = HelpContent.labelWithIconList( moveInSmallerStepsText, [ shiftPlusArrowKeys, shiftPlusWASDKeys ], moveInSmallerStepsWithString ); + const moveInSmallerStepsText = new RichText( moveInSmallerStepsString, DEFAULT_LABEL_OPTIONS ); + const shiftPlusArrowKeys = HelpContent.shiftPlusIcon( HelpContent.arrowKeysRowIcon() ); + const shiftPlusWASDKeys = HelpContent.shiftPlusIcon( HelpContent.wasdRowIcon() ); + const row = HelpContent.labelWithIconList( moveInSmallerStepsText, [ shiftPlusArrowKeys, shiftPlusWASDKeys ], moveInSmallerStepsWithString ); HelpContent.call( this, moveBookHeaderString, [ moveBookRow, row ], options ); } diff --git a/js/friction/view/FrictionScreenSummaryNode.js b/js/friction/view/FrictionScreenSummaryNode.js index e20fe097..14fa9fcb 100644 --- a/js/friction/view/FrictionScreenSummaryNode.js +++ b/js/friction/view/FrictionScreenSummaryNode.js @@ -151,7 +151,7 @@ define( require => { } // cancel out the range - let normalized = ( amplitude - this.thermometerMinTemp ) / this.thermometerMaxTemp; + const normalized = ( amplitude - this.thermometerMinTemp ) / this.thermometerMaxTemp; let i = Math.floor( normalized * stringsList.length ); // to account for javascript rounding problems @@ -171,7 +171,7 @@ define( require => { * @returns {string} the temp string based on the amplitude of the model */ amplitudeToTempString( amplitude ) { - let i = this.amplitudeToIndex( amplitude, FrictionConstants.TEMPERATURE_STRINGS ); + const i = this.amplitudeToIndex( amplitude, FrictionConstants.TEMPERATURE_STRINGS ); return FrictionConstants.TEMPERATURE_STRINGS[ i ]; } @@ -183,7 +183,7 @@ define( require => { * @returns {string} the "jiggle" amount string based on the amplitude of the model */ amplitudeToJiggleString( amplitude ) { - let i = this.amplitudeToIndex( amplitude, FrictionConstants.JIGGLE_STRINGS ); + const i = this.amplitudeToIndex( amplitude, FrictionConstants.JIGGLE_STRINGS ); return FrictionConstants.JIGGLE_STRINGS[ i ]; } @@ -195,7 +195,7 @@ define( require => { getSecondSummarySentence( amplitudeProperty ) { // {{boolean}} is sim "in transition"? meaning it is changing, because it isn't settled (settled is the opposite of "in transition" - let inTransition = amplitudeProperty.value > FrictionModel.AMPLITUDE_SETTLED_THRESHOLD; + const inTransition = amplitudeProperty.value > FrictionModel.AMPLITUDE_SETTLED_THRESHOLD; // Default to describing the jiggling of the atoms @@ -214,7 +214,7 @@ define( require => { } // Fill in the current temperature string - let tempString = StringUtils.fillIn( temperaturePatternString, { + const tempString = StringUtils.fillIn( temperaturePatternString, { temp: this.amplitudeToTempString( amplitudeProperty.value ), thermometer: inTransition ? '' : thermometerString } ); @@ -246,13 +246,13 @@ define( require => { updateSummaryString() { // FIRST SENTENCE - let chemistryBookString = this.getFirstSummarySentence( this.model.numberOfAtomsEvaporated ); + const chemistryBookString = this.getFirstSummarySentence( this.model.numberOfAtomsEvaporated ); // SECOND SENTENCE (ZOOMED-IN) - let jiggleTempSentence = this.getSecondSummarySentence( this.model.amplitudeProperty ); + const jiggleTempSentence = this.getSecondSummarySentence( this.model.amplitudeProperty ); // SUPPLEMENTARY THIRD SENTENCE - let supplementarySentence = this.getThirdSupplementarySentence( this.model.numberOfAtomsEvaporated ); + const supplementarySentence = this.getThirdSupplementarySentence( this.model.numberOfAtomsEvaporated ); this.booksParagraph.innerContent = StringUtils.fillIn( summarySentencePatternString, { chemistryBookString: chemistryBookString, diff --git a/js/friction/view/FrictionScreenView.js b/js/friction/view/FrictionScreenView.js index 114429f9..39d06e15 100644 --- a/js/friction/view/FrictionScreenView.js +++ b/js/friction/view/FrictionScreenView.js @@ -75,7 +75,7 @@ define( function( require ) { BookMovementDescriber.initialize( model ); // a11y - let frictionSummaryNode = new FrictionScreenSummaryNode( model, THERMOMETER_MIN_TEMP, THERMOMETER_MAX_TEMP ); + const frictionSummaryNode = new FrictionScreenSummaryNode( model, THERMOMETER_MIN_TEMP, THERMOMETER_MAX_TEMP ); this.screenSummaryNode.addChild( frictionSummaryNode ); // add physics book @@ -86,7 +86,7 @@ define( function( require ) { } ) ); // add chemistry book - let chemistryBookNode = new BookNode( model, chemistryString, { + const chemistryBookNode = new BookNode( model, chemistryString, { x: 65, y: 209, color: FrictionConstants.TOP_BOOK_COLOR_MACRO, @@ -142,14 +142,14 @@ define( function( require ) { } ) ); - let playAreaNode = new PlayAreaNode(); + const playAreaNode = new PlayAreaNode(); this.addChild( playAreaNode ); // a11y playAreaNode.accessibleOrder = [ chemistryBookNode, this.magnifierNode ]; // add reset button - let resetAllButton = new ResetAllButton( { + const resetAllButton = new ResetAllButton( { listener: function() { model.reset(); self.reset(); @@ -200,7 +200,7 @@ define( function( require ) { } ); // add a node that creates a "play area" accessible section in the PDOM - let controlAreaNode = new ControlAreaNode(); + const controlAreaNode = new ControlAreaNode(); this.addChild( controlAreaNode ); controlAreaNode.accessibleOrder = [ resetAllButton ]; diff --git a/js/friction/view/book/BookNode.js b/js/friction/view/book/BookNode.js index 6759b60a..c2dd1362 100644 --- a/js/friction/view/book/BookNode.js +++ b/js/friction/view/book/BookNode.js @@ -34,12 +34,12 @@ define( function( require ) { const simpleDropSound = require( 'sound!FRICTION/simple-drop.mp3' ); // a11y strings - let bookTitleStringPattern = FrictionA11yStrings.bookTitleStringPattern.value; - let zoomedInChemistryBookPatternString = FrictionA11yStrings.zoomedInChemistryBookPattern.value; - let grabButtonHelpTextString = FrictionA11yStrings.grabButtonHelpText.value; + const bookTitleStringPattern = FrictionA11yStrings.bookTitleStringPattern.value; + const zoomedInChemistryBookPatternString = FrictionA11yStrings.zoomedInChemistryBookPattern.value; + const grabButtonHelpTextString = FrictionA11yStrings.grabButtonHelpText.value; // constants - let SOUND_LEVEL = 0.1; // TODO: Ashton - level for non-magnified book pickup and drop, review and modify if needed + const SOUND_LEVEL = 0.1; // TODO: Ashton - level for non-magnified book pickup and drop, review and modify if needed /** * @param {FrictionModel} model @@ -48,7 +48,7 @@ define( function( require ) { * @constructor */ function BookNode( model, title, options ) { - let self = this; + const self = this; options = _.extend( { @@ -69,11 +69,11 @@ define( function( require ) { if ( options.drag ) { // We want the focus highlight to be completely within the bounds of the book. - let focusHighlightRect = new FocusHighlightPath( null ); - let focusHighlightLineWidth = focusHighlightRect.getOuterLineWidth( this ); + const focusHighlightRect = new FocusHighlightPath( null ); + const focusHighlightLineWidth = focusHighlightRect.getOuterLineWidth( this ); focusHighlightRect.setShape( Shape.bounds( this.localBounds.eroded( focusHighlightLineWidth / 2 ) ) ); - let bookTitle = StringUtils.fillIn( bookTitleStringPattern, { bookTitle: title } ); + const bookTitle = StringUtils.fillIn( bookTitleStringPattern, { bookTitle: title } ); // cuing arrows for the book const bookCueArrow1 = new CueArrow( { diff --git a/js/friction/view/book/CoverNode.js b/js/friction/view/book/CoverNode.js index bb80bffa..337171ff 100644 --- a/js/friction/view/book/CoverNode.js +++ b/js/friction/view/book/CoverNode.js @@ -22,13 +22,13 @@ define( function( require ) { const Text = require( 'SCENERY/nodes/Text' ); // constants - let FONT = new PhetFont( 22 ); - let WIDTH = 200; - let HEIGHT = 30; - let ROUND = 5; - let PAGES = 8; - let LENGTH = 75; - let ANGLE = Math.PI / 12; + const FONT = new PhetFont( 22 ); + const WIDTH = 200; + const HEIGHT = 30; + const ROUND = 5; + const PAGES = 8; + const LENGTH = 75; + const ANGLE = Math.PI / 12; /** * @param {string} title @@ -69,7 +69,7 @@ define( function( require ) { fill: options.color, stroke: options.stroke } ) ); - let titleNode = new Text( title, { + const titleNode = new Text( title, { font: FONT, fill: FrictionConstants.BOOK_TEXT_COLOR, pickable: false @@ -90,9 +90,9 @@ define( function( require ) { // add remaining pages for ( let i = 0, dy = ( HEIGHT - ROUND ) / PAGES, dl = LENGTH / 5, offset = 5; i < PAGES; i++ ) { - let amplitude = ( LENGTH - offset + dl * ( Math.pow( 1 / 2 - i / PAGES, 2 ) - 1 / 4 ) ); - let x2 = WIDTH + ROUND / 2 + Math.cos( ANGLE ) * amplitude; - let y2 = ROUND / 2 + dy * i - Math.sin( ANGLE ) * amplitude; + const amplitude = ( LENGTH - offset + dl * ( Math.pow( 1 / 2 - i / PAGES, 2 ) - 1 / 4 ) ); + const x2 = WIDTH + ROUND / 2 + Math.cos( ANGLE ) * amplitude; + const y2 = ROUND / 2 + dy * i - Math.sin( ANGLE ) * amplitude; this.addChild( new Path( new Shape() .moveTo( WIDTH + ROUND / 2, ROUND / 2 + dy * i ) .lineTo( x2, y2 ), { diff --git a/js/friction/view/describers/TemperatureDecreasingDescriber.js b/js/friction/view/describers/TemperatureDecreasingDescriber.js index 3807d75a..01d3b057 100644 --- a/js/friction/view/describers/TemperatureDecreasingDescriber.js +++ b/js/friction/view/describers/TemperatureDecreasingDescriber.js @@ -145,7 +145,7 @@ define( require => { this.alertIndex++; var currentAlertIndex = Math.min( this.alertIndex, DECREASING.length - 1 ); - let alertObject = DECREASING[ currentAlertIndex ]; + const alertObject = DECREASING[ currentAlertIndex ]; FrictionAlertManager.alertTemperatureJiggleFromObject( alertObject, this.firstAlert, 'decreasing' ); diff --git a/js/friction/view/describers/TemperatureIncreasingDescriber.js b/js/friction/view/describers/TemperatureIncreasingDescriber.js index 355d6731..0f34d01b 100644 --- a/js/friction/view/describers/TemperatureIncreasingDescriber.js +++ b/js/friction/view/describers/TemperatureIncreasingDescriber.js @@ -149,9 +149,9 @@ define( ( require ) => { // @private alertIncrease() { this.alertIndex++; - let currentAlertIndex = Math.min( this.alertIndex, INCREASING.length - 1 ); + const currentAlertIndex = Math.min( this.alertIndex, INCREASING.length - 1 ); - let alertObject = INCREASING[ currentAlertIndex ]; + const alertObject = INCREASING[ currentAlertIndex ]; this.alert( () => { FrictionAlertManager.alertTemperatureJiggleFromObject( alertObject, false, 'increasing' ); diff --git a/js/friction/view/magnifier/AtomCanvasNode.js b/js/friction/view/magnifier/AtomCanvasNode.js index ee211d16..5e5326d2 100644 --- a/js/friction/view/magnifier/AtomCanvasNode.js +++ b/js/friction/view/magnifier/AtomCanvasNode.js @@ -16,15 +16,15 @@ define( function( require ) { const ShadedSphereNode = require( 'SCENERY_PHET/ShadedSphereNode' ); // constants - let PARTICLE_IMAGE_SIZE = 32; // pixels, square - let ATOM_NODE_LINE_WIDTH = 2; - let HIGHLIGHT_FACTOR = 0.7; - let ATOM_STROKE = 'black'; + const PARTICLE_IMAGE_SIZE = 32; // pixels, square + const ATOM_NODE_LINE_WIDTH = 2; + const HIGHLIGHT_FACTOR = 0.7; + const ATOM_STROKE = 'black'; // image size - this is tweaked slightly to account for stroke and to get behavior that is consistent with // previous versions of the sim - let PARTICLE_IMAGE_SIZE_FOR_RENDERING = FrictionConstants.ATOM_RADIUS * 2 * 1.2; - let PARTICLE_RENDERING_OFFSET = -PARTICLE_IMAGE_SIZE_FOR_RENDERING / 2; + const PARTICLE_IMAGE_SIZE_FOR_RENDERING = FrictionConstants.ATOM_RADIUS * 2 * 1.2; + const PARTICLE_RENDERING_OFFSET = -PARTICLE_IMAGE_SIZE_FOR_RENDERING / 2; /** * @param {Object} [options] @@ -32,11 +32,11 @@ define( function( require ) { */ function AtomCanvasNode( atoms, options ) { - let self = this; + const self = this; CanvasNode.call( this, options ); // create the Scenery image nodes that will be drawn onto the canvas in order to render the atoms - let topBookAtomNode = new ShadedSphereNode( PARTICLE_IMAGE_SIZE, { + const topBookAtomNode = new ShadedSphereNode( PARTICLE_IMAGE_SIZE, { mainColor: FrictionConstants.TOP_BOOK_ATOMS_COLOR, highlightColor: FrictionConstants.TOP_BOOK_ATOMS_COLOR.colorUtilsBrighter( HIGHLIGHT_FACTOR ), stroke: ATOM_STROKE, @@ -46,7 +46,7 @@ define( function( require ) { self.topBookAtomImage = image; } ); - let bottomBookAtomNode = new ShadedSphereNode( PARTICLE_IMAGE_SIZE, { + const bottomBookAtomNode = new ShadedSphereNode( PARTICLE_IMAGE_SIZE, { mainColor: FrictionConstants.BOTTOM_BOOK_ATOMS_COLOR, highlightColor: FrictionConstants.BOTTOM_BOOK_ATOMS_COLOR.colorUtilsBrighter( HIGHLIGHT_FACTOR ), stroke: ATOM_STROKE, @@ -76,9 +76,9 @@ define( function( require ) { // render each of the atoms to the canvas for ( let i = 0; i < this.atoms.length; i++ ) { - let atom = this.atoms[ i ]; - let atomPosition = atom.positionProperty.get(); - let sourceImage = atom.isTopAtom ? this.topBookAtomImage : this.bottomBookAtomImage; + const atom = this.atoms[ i ]; + const atomPosition = atom.positionProperty.get(); + const sourceImage = atom.isTopAtom ? this.topBookAtomImage : this.bottomBookAtomImage; context.drawImage( sourceImage, atomPosition.x + PARTICLE_RENDERING_OFFSET, diff --git a/js/friction/view/magnifier/MagnifierNode.js b/js/friction/view/magnifier/MagnifierNode.js index f4ccc833..db3f199c 100644 --- a/js/friction/view/magnifier/MagnifierNode.js +++ b/js/friction/view/magnifier/MagnifierNode.js @@ -38,22 +38,22 @@ define( function( require ) { const Vector2 = require( 'DOT/Vector2' ); // a11y strings - let bookTitleStringPattern = FrictionA11yStrings.bookTitleStringPattern.value; - let zoomedInBookTitlePatternString = FrictionA11yStrings.zoomedInBookTitlePattern.value; - let zoomedInString = FrictionA11yStrings.zoomedIn.value; - let zoomedInChemistryBookPatternString = FrictionA11yStrings.zoomedInChemistryBookPattern.value; + const bookTitleStringPattern = FrictionA11yStrings.bookTitleStringPattern.value; + const zoomedInBookTitlePatternString = FrictionA11yStrings.zoomedInBookTitlePattern.value; + const zoomedInString = FrictionA11yStrings.zoomedIn.value; + const zoomedInChemistryBookPatternString = FrictionA11yStrings.zoomedInChemistryBookPattern.value; // sounds const harpDropSound = require( 'sound!FRICTION/harp-drop.mp3' ); const harpPickupSound = require( 'sound!FRICTION/harp-pickup.mp3' ); // constants - let WIDTH = FrictionConstants.MAGNIFIER_WINDOW_WIDTH; - let HEIGHT = FrictionConstants.MAGNIFIER_WINDOW_HEIGHT; - let ROUND = 30; - let SCALE = 0.05; - let SOUND_LEVEL = 0.1; // TODO: Ashton - level for magnified book pickup and drop, review and modify if needed - let ARROW_TOP = 22; + const WIDTH = FrictionConstants.MAGNIFIER_WINDOW_WIDTH; + const HEIGHT = FrictionConstants.MAGNIFIER_WINDOW_HEIGHT; + const ROUND = 30; + const SCALE = 0.05; + const SOUND_LEVEL = 0.1; // TODO: Ashton - level for magnified book pickup and drop, review and modify if needed + const ARROW_TOP = 22; /** * @param {FrictionModel} model @@ -75,9 +75,9 @@ define( function( require ) { this.topAtomsLayer = new Node(); // arrow icon - let leftArrow = new CueArrow( { rotation: Math.PI, fill: 'white' } ); - let rightArrow = new CueArrow( { fill: 'white' } ); - let visualArrowIcon = new HBox( { + const leftArrow = new CueArrow( { rotation: Math.PI, fill: 'white' } ); + const rightArrow = new CueArrow( { fill: 'white' } ); + const visualArrowIcon = new HBox( { children: [ leftArrow, rightArrow ], spacing: 20, centerX: WIDTH / 2, @@ -123,7 +123,7 @@ define( function( require ) { this.topBookBackground = new Node(); // init drag for background - let background = new Rectangle( + const background = new Rectangle( -1.125 * WIDTH, -HEIGHT, 3.25 * WIDTH, @@ -142,12 +142,12 @@ define( function( require ) { this.topBookBackground.addChild( background ); // init drag for drag area - let zoomedInTitle = StringUtils.fillIn( zoomedInBookTitlePatternString, { + const zoomedInTitle = StringUtils.fillIn( zoomedInBookTitlePatternString, { bookTitleString: StringUtils.fillIn( bookTitleStringPattern, { bookTitle: title } ) } ); - let dragArea = new Rectangle( + const dragArea = new Rectangle( 0.055 * WIDTH, 0.175 * HEIGHT, 0.875 * WIDTH, @@ -166,7 +166,7 @@ define( function( require ) { } ) ); // a11y - custom shape for the focus highlight, shape will change with atomRowsToEvaporateProperty - let focusHighlightPath = new FocusHighlightPath( getFocusHighlightShape( dragArea ) ); + const focusHighlightPath = new FocusHighlightPath( getFocusHighlightShape( dragArea ) ); // cuing arrows for the book const bookCueArrowLeft = new CueArrow( { @@ -174,7 +174,7 @@ define( function( require ) { } ); const bookCueArrowRight = new CueArrow(); - let horizontalCueArrows = new HBox( { + const horizontalCueArrows = new HBox( { children: [ bookCueArrowLeft, bookCueArrowRight ], spacing: 30, // to be scaled down below centerX: WIDTH / 2, @@ -199,7 +199,7 @@ define( function( require ) { this.keyboardDragHandler = new FrictionKeyboardDragListener( model ); // alert the temperature state on focus - let focusListener = { + const focusListener = { focus() { if ( model.amplitudeProperty.value === model.amplitudeProperty.initialValue ) { FrictionAlertManager.alertSettledAndCool(); @@ -257,17 +257,17 @@ define( function( require ) { this.container.addChild( this.topBookBackground ); // Add the red border around the magnified area, and add a white shape below it to block out the clipped area. - let topPadding = 500; - let sidePadding = 800; - let bottomPadding = 10; // don't go too far below the magnifier - let rightX = WIDTH + sidePadding; - let leftX = -sidePadding; - let topY = -topPadding; - let bottomY = HEIGHT + bottomPadding; - let innerLowX = ROUND; - let innerHighX = WIDTH - ROUND; - let innerLowY = ROUND; - let innerHighY = HEIGHT - ROUND; + const topPadding = 500; + const sidePadding = 800; + const bottomPadding = 10; // don't go too far below the magnifier + const rightX = WIDTH + sidePadding; + const leftX = -sidePadding; + const topY = -topPadding; + const bottomY = HEIGHT + bottomPadding; + const innerLowX = ROUND; + const innerHighX = WIDTH - ROUND; + const innerLowY = ROUND; + const innerHighY = HEIGHT - ROUND; this.addChild( new Path( new Shape().moveTo( rightX, topY ) .lineTo( leftX, topY ) .lineTo( leftX, bottomY ) @@ -290,7 +290,7 @@ define( function( require ) { } ) ); // add magnifier's target - let magnifierTargetNode = new MagnifierTargetNode( + const magnifierTargetNode = new MagnifierTargetNode( targetX, targetY, WIDTH * SCALE, @@ -332,7 +332,7 @@ define( function( require ) { // helper function that adds a row of circles at the specified location, used to add bumps to the magnified books function addRowCircles( circleRadius, xSpacing, parentNode, options ) { - let numberOfAtomsForRow = options.width / xSpacing; + const numberOfAtomsForRow = options.width / xSpacing; for ( let i = 0; i < numberOfAtomsForRow; i++ ) { parentNode.addChild( new Circle( circleRadius, { fill: options.color, diff --git a/js/friction/view/magnifier/MagnifierTargetNode.js b/js/friction/view/magnifier/MagnifierTargetNode.js index a1393afa..eaffe4b8 100644 --- a/js/friction/view/magnifier/MagnifierTargetNode.js +++ b/js/friction/view/magnifier/MagnifierTargetNode.js @@ -38,19 +38,19 @@ define( function( require ) { Node.call( this ); - let rectangle = new Rectangle( 0, 0, width, height, cornerRadius, cornerRadius, { + const rectangle = new Rectangle( 0, 0, width, height, cornerRadius, cornerRadius, { stroke: options.stroke, lineWidth: 1 } ); this.addChild( rectangle ); - let pathLeft = new Path( new Shape() + const pathLeft = new Path( new Shape() .moveToPoint( leftAnchor ) .lineTo( x - width / 2, y ), { stroke: options.stroke, lineDash: [ 10, 10 ] } ); this.addChild( pathLeft ); - let pathRight = new Path( new Shape() + const pathRight = new Path( new Shape() .moveToPoint( rightAnchor ) .lineTo( x + width / 2, y ), { stroke: options.stroke,