@@ -560,6 +560,15 @@ class InputSpinner extends Component {
560560 return time < minInterval ? minInterval : time ;
561561 }
562562
563+ /**
564+ * On hold increase
565+ * @param event
566+ * @returns {Promise<void> }
567+ */
568+ async increaseHold ( event ) {
569+ this . increase ( event , true ) ;
570+ }
571+
563572 /**
564573 * Increase
565574 * @param event
@@ -599,20 +608,32 @@ class InputSpinner extends Component {
599608 }
600609
601610 let wait = this . _getHoldChangeInterval ( ) ;
602- if ( this . increaseTimer === null ) {
611+ if ( ! isLongPress && this . increaseTimer === null ) {
603612 this . _startHoldTime ( ) ;
604613 wait = this . props . accelerationDelay ;
605- } else {
614+ } else if ( isLongPress ) {
606615 this . onLongPress ( num ) ;
607616 }
608617
609- this . increaseTimer = setTimeout (
610- this . increase . bind ( this , event , true ) ,
611- wait ,
612- ) ;
618+ if ( isLongPress ) {
619+ this . increaseTimer = setTimeout (
620+ this . increase . bind ( this , event , true ) ,
621+ wait ,
622+ ) ;
623+ }
624+
613625 this . onChange ( num , true ) ;
614626 }
615627
628+ /**
629+ * On hold decrease
630+ * @param event
631+ * @returns {Promise<void> }
632+ */
633+ async decreaseHold ( event ) {
634+ this . decrease ( event , true ) ;
635+ }
636+
616637 /**
617638 * Decrease
618639 * @param event
@@ -652,17 +673,20 @@ class InputSpinner extends Component {
652673 }
653674
654675 let wait = this . _getHoldChangeInterval ( ) ;
655- if ( this . decreaseTimer === null ) {
676+ if ( ! isLongPress && this . decreaseTimer === null ) {
656677 this . _startHoldTime ( ) ;
657678 wait = this . props . accelerationDelay ;
658- } else {
679+ } else if ( isLongPress ) {
659680 this . onLongPress ( num ) ;
660681 }
661682
662- this . decreaseTimer = setTimeout (
663- this . decrease . bind ( this , event , true ) ,
664- wait ,
665- ) ;
683+ if ( isLongPress ) {
684+ this . decreaseTimer = setTimeout (
685+ this . decrease . bind ( this , event , true ) ,
686+ wait ,
687+ ) ;
688+ }
689+
666690 this . onChange ( num , true ) ;
667691 }
668692
@@ -1101,6 +1125,8 @@ class InputSpinner extends Component {
11011125 style = { buttonStyle }
11021126 onPressIn = { this . decrease . bind ( this ) }
11031127 onPressOut = { this . onPressOut . bind ( this ) }
1128+ onLongPress = { this . decreaseHold . bind ( this ) }
1129+ delayLongPress = { this . props . accelerationDelay }
11041130 { ...this . props . leftButtonProps } >
11051131 { this . _renderLeftButtonElement ( ) }
11061132 </ TouchableHighlight >
@@ -1137,6 +1163,8 @@ class InputSpinner extends Component {
11371163 style = { buttonStyle }
11381164 onPressIn = { this . increase . bind ( this ) }
11391165 onPressOut = { this . onPressOut . bind ( this ) }
1166+ onLongPress = { this . increaseHold . bind ( this ) }
1167+ delayLongPress = { this . props . accelerationDelay }
11401168 { ...this . props . rightButtonProps } >
11411169 { this . _renderRightButtonElement ( ) }
11421170 </ TouchableHighlight >
0 commit comments