@@ -33,6 +33,10 @@ class InputSpinner extends Component {
3333 if ( ! this . isTypeDecimal ( ) && spinnerStep < 1 ) {
3434 spinnerStep = 1 ;
3535 }
36+ let spinnerLongStep = this . _parseNum ( this . props . longStep ) ;
37+ if ( ! this . isTypeDecimal ( ) && spinnerLongStep < 1 ) {
38+ spinnerLongStep = 0 ;
39+ }
3640
3741 const min = this . props . min != null ? this . _parseNum ( this . props . min ) : null ;
3842 const max = this . props . max != null ? this . _parseNum ( this . props . max ) : null ;
@@ -62,6 +66,7 @@ class InputSpinner extends Component {
6266 max : max ,
6367 value : initialValue ,
6468 step : spinnerStep ,
69+ longStep : spinnerLongStep ,
6570 focused : false ,
6671 buttonPress : null ,
6772 } ;
@@ -99,6 +104,14 @@ class InputSpinner extends Component {
99104 }
100105 this . setState ( { step : spinnerStep } ) ;
101106 }
107+ // Parse longStep
108+ if ( this . props . longStep !== prevProps . longStep ) {
109+ let spinnerLongStep = this . _parseNum ( this . props . longStep ) ;
110+ if ( ! this . isTypeDecimal ( ) && spinnerLongStep < 1 ) {
111+ spinnerLongStep = 0 ;
112+ }
113+ this . setState ( { longStep : spinnerLongStep } ) ;
114+ }
102115 }
103116
104117 /**
@@ -549,11 +562,23 @@ class InputSpinner extends Component {
549562
550563 /**
551564 * Increase
565+ * @param event
566+ * @param isLongPress
567+ * @returns {Promise<void> }
552568 */
553- async increase ( ) {
569+ async increase ( event , isLongPress = false ) {
554570 if ( this . _isDisabledButtonRight ( ) ) return ;
555571 let currentValue = this . _parseNum ( this . state . value ) ;
556- let num = currentValue + this . _parseNum ( this . state . step ) ;
572+ let num =
573+ currentValue +
574+ this . _parseNum (
575+ isLongPress && this . state . longStep > 0
576+ ? this . state . longStep
577+ : this . state . step ,
578+ ) ;
579+ if ( isLongPress && this . state . longStep > 0 ) {
580+ num = Math . round ( num / this . state . longStep ) * this . state . longStep ;
581+ }
557582
558583 if (
559584 this . isMaxReached ( currentValue ) &&
@@ -581,17 +606,32 @@ class InputSpinner extends Component {
581606 this . onLongPress ( num ) ;
582607 }
583608
584- this . increaseTimer = setTimeout ( this . increase . bind ( this ) , wait ) ;
609+ this . increaseTimer = setTimeout (
610+ this . increase . bind ( this , event , true ) ,
611+ wait ,
612+ ) ;
585613 this . onChange ( num , true ) ;
586614 }
587615
588616 /**
589617 * Decrease
618+ * @param event
619+ * @param isLongPress
620+ * @returns {Promise<void> }
590621 */
591- async decrease ( ) {
622+ async decrease ( event , isLongPress = false ) {
592623 if ( this . _isDisabledButtonLeft ( ) ) return ;
593624 let currentValue = this . _parseNum ( this . state . value ) ;
594- let num = currentValue - this . _parseNum ( this . state . step ) ;
625+ let num =
626+ currentValue -
627+ this . _parseNum (
628+ isLongPress && this . state . longStep > 0
629+ ? this . state . longStep
630+ : this . state . step ,
631+ ) ;
632+ if ( isLongPress && this . state . longStep > 0 ) {
633+ num = Math . round ( num / this . state . longStep ) * this . state . longStep ;
634+ }
595635
596636 if (
597637 this . isMinReached ( currentValue ) &&
@@ -619,7 +659,10 @@ class InputSpinner extends Component {
619659 this . onLongPress ( num ) ;
620660 }
621661
622- this . decreaseTimer = setTimeout ( this . decrease . bind ( this ) , wait ) ;
662+ this . decreaseTimer = setTimeout (
663+ this . decrease . bind ( this , event , true ) ,
664+ wait ,
665+ ) ;
623666 this . onChange ( num , true ) ;
624667 }
625668
@@ -1149,6 +1192,7 @@ InputSpinner.propTypes = {
11491192 value : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11501193 initialValue : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11511194 step : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
1195+ longStep : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11521196 precision : PropTypes . number ,
11531197 shadow : PropTypes . bool ,
11541198 rounded : PropTypes . bool ,
@@ -1223,6 +1267,7 @@ InputSpinner.defaultProps = {
12231267 value : 0 ,
12241268 initialValue : null ,
12251269 step : 1 ,
1270+ longStep : 0 ,
12261271 precision : 2 ,
12271272 rounded : true ,
12281273 shadow : false ,
0 commit comments