From b23489006e6b86fb05a93f7a95032005aa10ffab Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 26 Mar 2021 11:46:08 -0800 Subject: [PATCH] prefer Utils.toFixed when possible, https://github.com/phetsims/chipper/issues/737 --- js/common/model/RAPRatio.js | 2 +- js/common/view/RatioHandNode.js | 2 +- js/common/view/getKeyboardInputSnappingMapper.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/common/model/RAPRatio.js b/js/common/model/RAPRatio.js index 1d8d2f12..28b55017 100644 --- a/js/common/model/RAPRatio.js +++ b/js/common/model/RAPRatio.js @@ -107,7 +107,7 @@ class RAPRatio { if ( this.enabledRatioTermsRangeProperty.value.contains( oldTuple.antecedent ) && this.enabledRatioTermsRangeProperty.value.contains( oldTuple.consequent ) && antecedentChanged && consequentChanged ) { - assert && assert( RAPConstants.toFixed( tuple.getRatio() ) === RAPConstants.toFixed( oldTuple.getRatio() ), + assert && assert( RAPConstants.toFixed( tuple.getRatio() ) === RAPConstants.toFixed( oldTuple.getRatio() ), // eslint-disable-line bad-sim-text 'if both values change while locked, the ratio should be maintained.' ); } diff --git a/js/common/view/RatioHandNode.js b/js/common/view/RatioHandNode.js index 06899418..ca60a3d4 100644 --- a/js/common/view/RatioHandNode.js +++ b/js/common/view/RatioHandNode.js @@ -44,7 +44,7 @@ class RatioHandNode extends Node { constructor( valueProperty, enabledRatioTermsRangeProperty, tickMarkViewProperty, keyboardStep, colorProperty, cueDisplayProperty, getIdealValue, inProportionProperty, options ) { - const shiftKeyboardStep = RAPConstants.toFixed( keyboardStep * RAPConstants.SHIFT_KEY_MULTIPLIER ); + const shiftKeyboardStep = RAPConstants.toFixed( keyboardStep * RAPConstants.SHIFT_KEY_MULTIPLIER ); // eslint-disable-line bad-sim-text // Conserve keypresses while allowing keyboard input to access any "in-proportion" state, even if more granular than // the keyboard step size allows. diff --git a/js/common/view/getKeyboardInputSnappingMapper.js b/js/common/view/getKeyboardInputSnappingMapper.js index 197b5ff1..05b32e51 100644 --- a/js/common/view/getKeyboardInputSnappingMapper.js +++ b/js/common/view/getKeyboardInputSnappingMapper.js @@ -27,7 +27,7 @@ function getKeyboardInputSnappingMapper( getIdealValue, keyboardStep, shiftKeybo const snappingFunction = ( newValue, oldValue, useShiftKeyStep, alreadyInProportion ) => { // Don't conserve the snap for page up/down or home/end keys, just basic movement changes. - const applyConservationSnap = RAPConstants.toFixed( Math.abs( newValue - oldValue ) ) <= shiftKeyboardStep && + const applyConservationSnap = RAPConstants.toFixed( Math.abs( newValue - oldValue ) ) <= shiftKeyboardStep && // eslint-disable-line bad-sim-text newValue > RAPConstants.NO_SUCCESS_VALUE_THRESHOLD && oldValue > RAPConstants.NO_SUCCESS_VALUE_THRESHOLD; @@ -35,7 +35,7 @@ function getKeyboardInputSnappingMapper( getIdealValue, keyboardStep, shiftKeybo // Default case if there is no saved remainder, then just step normally. if ( remainder === 0 ) { const snapToKeyboardStep = useShiftKeyStep ? shiftKeyboardStep : keyboardStep; - newValue = RAPConstants.toFixed( + newValue = RAPConstants.toFixed( // eslint-disable-line bad-sim-text Utils.roundSymmetric( newValue / snapToKeyboardStep ) * snapToKeyboardStep, Utils.numberOfDecimalPlaces( snapToKeyboardStep ) ); }