Доработки NumInput
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
:class="(validate(modelValue - step) ? '' : 'disable')"
|
:class="(validate(modelValue - step) ? '' : 'disable')"
|
||||||
:name="minusIcon"
|
:name="minusIcon"
|
||||||
class="button"
|
class="button"
|
||||||
@click="minus"
|
@click="onClick('minus')"
|
||||||
@mousedown.prevent.stop="onMouseDown($event, 'minus')"
|
@mousedown.prevent.stop="onMouseDown($event, 'minus')"
|
||||||
@mouseup.prevent.stop="onMouseUp"
|
@mouseup.prevent.stop="onMouseUp"
|
||||||
@mouseout.prevent.stop="onMouseUp"
|
@mouseout.prevent.stop="onMouseUp"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
:class="(validate(modelValue + step) ? '' : 'disable')"
|
:class="(validate(modelValue + step) ? '' : 'disable')"
|
||||||
:name="plusIcon"
|
:name="plusIcon"
|
||||||
class="button"
|
class="button"
|
||||||
@click="plus"
|
@click="onClick('plus')"
|
||||||
@mousedown.prevent.stop="onMouseDown($event, 'plus')"
|
@mousedown.prevent.stop="onMouseDown($event, 'plus')"
|
||||||
@mouseup.prevent.stop="onMouseUp"
|
@mouseup.prevent.stop="onMouseUp"
|
||||||
@mouseout.prevent.stop="onMouseUp"
|
@mouseout.prevent.stop="onMouseUp"
|
||||||
@@ -109,23 +109,42 @@ class NumInput {
|
|||||||
this.filteredValue = newValue;
|
this.filteredValue = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClick(way) {
|
||||||
|
if (this.clickRepeat)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (way == 'plus') {
|
||||||
|
this.plus();
|
||||||
|
} else {
|
||||||
|
this.minus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMouseDown(event, way) {
|
onMouseDown(event, way) {
|
||||||
this.startClickRepeat = true;
|
this.startClickRepeat = true;
|
||||||
this.clickRepeat = false;
|
this.clickRepeat = false;
|
||||||
|
|
||||||
if (event.button == 0) {
|
if (event.button == 0) {
|
||||||
(async() => {
|
(async() => {
|
||||||
await utils.sleep(300);
|
if (this.inRepeatFunc)
|
||||||
if (this.startClickRepeat) {
|
return;
|
||||||
this.clickRepeat = true;
|
|
||||||
while (this.clickRepeat) {
|
this.inRepeatFunc = true;
|
||||||
if (way == 'plus') {
|
try {
|
||||||
this.plus();
|
await utils.sleep(300);
|
||||||
} else {
|
if (this.startClickRepeat) {
|
||||||
this.minus();
|
this.clickRepeat = true;
|
||||||
|
while (this.clickRepeat) {
|
||||||
|
if (way == 'plus') {
|
||||||
|
this.plus();
|
||||||
|
} else {
|
||||||
|
this.minus();
|
||||||
|
}
|
||||||
|
await utils.sleep(200);
|
||||||
}
|
}
|
||||||
await utils.sleep(50);
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.inRepeatFunc = false;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@@ -135,7 +154,12 @@ class NumInput {
|
|||||||
if (this.inTouch)
|
if (this.inTouch)
|
||||||
return;
|
return;
|
||||||
this.startClickRepeat = false;
|
this.startClickRepeat = false;
|
||||||
this.clickRepeat = false;
|
if (this.clickRepeat) {
|
||||||
|
(async() => {
|
||||||
|
await utils.sleep(50);
|
||||||
|
this.clickRepeat = false;
|
||||||
|
})();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onTouchStart(event, way) {
|
onTouchStart(event, way) {
|
||||||
|
|||||||
Reference in New Issue
Block a user