Skip to content

Commit 6351de9

Browse files
committed
added longStep to have independent step for longPress
1 parent 660e4dd commit 6351de9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/InputSpinner.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class InputSpinner extends Component {
3535
}
3636
let spinnerLongStep = this._parseNum(this.props.longStep);
3737
if (!this.isTypeDecimal() && spinnerLongStep < 1) {
38-
spinnerLongStep = spinnerStep;
38+
spinnerLongStep = 0;
3939
}
4040

4141
const min = this.props.min != null ? this._parseNum(this.props.min) : null;
@@ -97,9 +97,8 @@ class InputSpinner extends Component {
9797
});
9898
}
9999
// Parse Step
100-
let spinnerStep;
101100
if (this.props.step !== prevProps.step) {
102-
spinnerStep = this._parseNum(this.props.step);
101+
let spinnerStep = this._parseNum(this.props.step);
103102
if (!this.isTypeDecimal() && spinnerStep < 1) {
104103
spinnerStep = 1;
105104
}
@@ -109,7 +108,7 @@ class InputSpinner extends Component {
109108
if (this.props.longStep !== prevProps.longStep) {
110109
let spinnerLongStep = this._parseNum(this.props.longStep);
111110
if (!this.isTypeDecimal() && spinnerLongStep < 1) {
112-
spinnerLongStep = spinnerStep;
111+
spinnerLongStep = 0;
113112
}
114113
this.setState({longStep: spinnerLongStep});
115114
}
@@ -568,8 +567,8 @@ class InputSpinner extends Component {
568567
async increase(event) {
569568
if (this._isDisabledButtonRight()) return;
570569
let currentValue = this._parseNum(this.state.value);
571-
let num = currentValue + this._parseNum(!event ? this.state.longStep : this.state.step);
572-
if (!event && this.state.longStep > 1) {
570+
let num = currentValue + this._parseNum((!event && this.state.longStep > 0) ? this.state.longStep : this.state.step);
571+
if (!event && this.state.longStep > 0) {
573572
num = Math.round(num / this.state.longStep) * this.state.longStep;
574573
}
575574

@@ -609,8 +608,8 @@ class InputSpinner extends Component {
609608
async decrease(event) {
610609
if (this._isDisabledButtonLeft()) return;
611610
let currentValue = this._parseNum(this.state.value);
612-
let num = currentValue - this._parseNum(!event ? this.state.longStep : this.state.step);
613-
if (!event && this.state.longStep > 1) {
611+
let num = currentValue - this._parseNum((!event && this.state.longStep > 0) ? this.state.longStep : this.state.step);
612+
if (!event && this.state.longStep > 0) {
614613
num = Math.round(num / this.state.longStep) * this.state.longStep;
615614
}
616615

0 commit comments

Comments
 (0)