Skip to content

Commit

Permalink
Remove unused second arg to RAPConstants.toFixed(), #243
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Dec 21, 2020
1 parent 476764c commit 71e5651
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions js/common/model/RAPModelTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ QUnit.test( 'keyboard input to model always can get in proportion: 2/7 moving do

newValue = snapConserveFunction( .11, ratioTupleProperty.value.antecedent, true );
ratioTupleProperty.value.antecedent = newValue;
const idealRatio = RAPConstants.toFixed( model.targetRatioProperty.value * ratioTupleProperty.value.consequent, 6 ); // to prevent rounding errors
const idealRatio = RAPConstants.toFixed( model.targetRatioProperty.value * ratioTupleProperty.value.consequent ); // to prevent rounding errors
assert.ok( ratioTupleProperty.value.antecedent === idealRatio, 'another step down should snap to in proportion' );

newValue = snapConserveFunction( ratioTupleProperty.value.antecedent - .01, ratioTupleProperty.value.antecedent, true );
Expand Down Expand Up @@ -74,7 +74,7 @@ QUnit.test( 'keyboard always can get in proportion: 2/7 moving up', assert => {

newValue = snapConserveFunction( .12, ratioTupleProperty.value.antecedent, true );
ratioTupleProperty.value.antecedent = newValue;
const idealAntecedent = RAPConstants.toFixed( model.targetRatioProperty.value * ratioTupleProperty.value.consequent, 6 ); // to prevent rounding errors
const idealAntecedent = RAPConstants.toFixed( model.targetRatioProperty.value * ratioTupleProperty.value.consequent ); // to prevent rounding errors
assert.ok( ratioTupleProperty.value.antecedent === idealAntecedent, 'step up through ideal' );

newValue = snapConserveFunction( ratioTupleProperty.value.antecedent + .01, ratioTupleProperty.value.antecedent, true );
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/describers/TickMarkDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class TickMarkDescriber {
const numberOfTickMarks = this.tickMarkRangeProperty.value;

// account for javascript rounding error
const expandedValue = RAPConstants.toFixed( normalized * numberOfTickMarks, 6 );
const expandedValue = RAPConstants.toFixed( normalized * numberOfTickMarks );

// account for javascript rounding error
const remainder = RAPConstants.toFixed( expandedValue % 1, 6 );
const remainder = RAPConstants.toFixed( expandedValue % 1 );

assert && assert( remainder < 1 && remainder >= 0, 'remainder not in range' );

Expand Down
8 changes: 4 additions & 4 deletions js/common/view/getKeyboardInputSnappingMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function getKeyboardInputSnappingMapper( getIdealValue, keyboardStep, shiftKeybo

const snappingFunction = ( newValue, oldValue, useShiftKeyStep ) => {
// 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 ), 6 ) <= shiftKeyboardStep;
const applyConservationSnap = RAPConstants.toFixed( Math.abs( newValue - oldValue ) ) <= shiftKeyboardStep;

if ( remainder === 0 ) {
const snapToKeyboardStep = useShiftKeyStep ? shiftKeyboardStep : keyboardStep;
Expand All @@ -39,9 +39,9 @@ function getKeyboardInputSnappingMapper( getIdealValue, keyboardStep, shiftKeybo
if ( applyConservationSnap ) {

let returnValue = newValue;
const target = RAPConstants.toFixed( getIdealValue(), 6 );
const target = RAPConstants.toFixed( getIdealValue() );
if ( newValue > target !== oldValue > target && oldValue !== target ) {
remainder = RAPConstants.toFixed( newValue - target, 6 );
remainder = RAPConstants.toFixed( newValue - target );
returnValue = target;
}

Expand All @@ -51,7 +51,7 @@ function getKeyboardInputSnappingMapper( getIdealValue, keyboardStep, shiftKeybo
returnValue = newValue;
}

returnValue = RAPConstants.toFixed( returnValue, 6 );
returnValue = RAPConstants.toFixed( returnValue );
assert && assert( !isNaN( returnValue ) );

return returnValue;
Expand Down

0 comments on commit 71e5651

Please sign in to comment.