@@ -36,7 +36,7 @@ class InputSpinner extends Component {
3636 ? this . props . initialValue
3737 : this . props . value ;
3838 initialValue = this . parseNum ( initialValue ) ;
39- initialValue = this . adjustValueLimits ( initialValue , min , max ) ;
39+ initialValue = this . withinRange ( initialValue , min , max ) ;
4040
4141 this . state = {
4242 min : min ,
@@ -57,7 +57,7 @@ class InputSpinner extends Component {
5757 // Parse Value
5858 if ( this . props . value !== prevProps . value ) {
5959 let newValue = this . parseNum ( this . props . value ) ;
60- newValue = this . adjustValueLimits ( newValue ) ;
60+ newValue = this . withinRange ( newValue ) ;
6161 this . setState ( { value : newValue } ) ;
6262 }
6363 // Parse Min
@@ -159,18 +159,26 @@ class InputSpinner extends Component {
159159 return num ;
160160 }
161161
162- adjustValueLimits ( value , min = null , max = null ) {
162+
163+ /**
164+ * Limit value to be within max and min range
165+ * @param value
166+ * @param min
167+ * @param max
168+ * @returns {* }
169+ */
170+ withinRange ( value , min = null , max = null ) {
163171 if ( min == null && this . state && this . state . min != null ) {
164172 min = this . state . min ;
165173 }
166174 if ( max == null && this . state && this . state . max != null ) {
167- min = this . state . max ;
175+ max = this . state . max ;
168176 }
169177 if ( min != null && value < min ) {
170- value = Math . min ( min , Math . max ( value , min ) ) ;
178+ value = min ;
171179 }
172180 if ( max != null && value > max ) {
173- value = Math . max ( max , Math . min ( value , max ) ) ;
181+ value = max ;
174182 }
175183 return value ;
176184 }
0 commit comments