Skip to content

Commit

Permalink
phetsims/tasks#275 replace Math.round with dot.Util.roundSymmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jun 19, 2015
1 parent f3ff1c1 commit 722f14c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/common/view/NumberControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ define( function( require ) {
var HookesLawFont = require( 'HOOKES_LAW/common/HookesLawFont' );
var HSlider = require( 'SUN/HSlider' );
var inherit = require( 'PHET_CORE/inherit' );
var Text = require( 'SCENERY/nodes/Text' );
var NumberDisplay = require( 'HOOKES_LAW/common/view/NumberDisplay' );
var Text = require( 'SCENERY/nodes/Text' );
var Util = require( 'DOT/Util' );
var VBox = require( 'SCENERY/nodes/VBox' );

// strings
Expand Down Expand Up @@ -72,14 +73,14 @@ define( function( require ) {

var leftArrowButton = new ArrowButton( 'left', function() {
var value = numberProperty.get() - delta;
value = Math.round( value / delta ) * delta; // constrain to delta
value = Util.roundSymmetric( value / delta ) * delta; // constrain to delta
value = Math.max( value, numberRange.min ); // constrain to range
numberProperty.set( value );
}, arrowButtonOptions );

var rightArrowButton = new ArrowButton( 'right', function() {
var value = numberProperty.get() + delta;
value = Math.round( value / delta ) * delta; // constrain to delta
value = Util.roundSymmetric( value / delta ) * delta; // constrain to delta
value = Math.min( value, numberRange.max ); // constrain to range
numberProperty.set( value );
}, arrowButtonOptions );
Expand All @@ -89,7 +90,7 @@ define( function( require ) {
endDrag: options.endCallback,
constrainValue: function( value ) {
// constrain to delta
value = Math.round( value / options.delta ) * options.delta;
value = Util.roundSymmetric( value / options.delta ) * options.delta;
// constrain to range
return numberRange.constrainValue( value );
}
Expand Down

0 comments on commit 722f14c

Please sign in to comment.