WIP Исправил ошибку срабатывания интервала
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
import BaseInput from "@/components/base/BaseInput";
|
||||
import BaseInputContainer from "@/components/base/BaseInputContainer.vue";
|
||||
import { ruleNumberInput } from "@/shared/utils/rulesInputs";
|
||||
import { roundedNumber } from "@/shared/utils/methodsObjects";
|
||||
|
||||
export default {
|
||||
name: "BaseInputNumber",
|
||||
@@ -58,7 +59,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
intervalId: 0,
|
||||
timeoutId: 0,
|
||||
ruleNumberInput: [(val) => ruleNumberInput(val, this.max, this.min)],
|
||||
roundedNumber: roundedNumber,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@@ -163,18 +166,23 @@ export default {
|
||||
}
|
||||
},
|
||||
fastIncrement() {
|
||||
this.timeoutId = setTimeout(() => {
|
||||
this.intervalId = setInterval(() => this.increment(), 100);
|
||||
}, 500);
|
||||
},
|
||||
fastDecrement() {
|
||||
this.timeoutId = setTimeout(() => {
|
||||
this.intervalId = setInterval(() => this.decrement(), 100);
|
||||
}, 500);
|
||||
},
|
||||
deleteInterval() {
|
||||
clearTimeout(this.timeoutId);
|
||||
clearInterval(this.intervalId);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.value = Number(val).toFixed(this.rounding);
|
||||
this.value = this.roundedNumber(val, this.rounding);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
|
||||
6
src/shared/utils/methodsObjects.js
Normal file
6
src/shared/utils/methodsObjects.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export function roundedNumber(val, digits, rounded = "floor") {
|
||||
let fraction = 10 * digits;
|
||||
return fraction
|
||||
? Math[rounded](val * fraction) / fraction
|
||||
: Math[rounded](val);
|
||||
}
|
||||
Reference in New Issue
Block a user