Доработки NumInput
This commit is contained in:
@@ -12,6 +12,9 @@
|
|||||||
class="button"
|
class="button"
|
||||||
:v-ripple="validate(value - step)"
|
:v-ripple="validate(value - step)"
|
||||||
@click="minus"
|
@click="minus"
|
||||||
|
@mousedown.prevent.stop="onMouseDown($event, 'minus')"
|
||||||
|
@mouseup.prevent.stop="onMouseUp($event, 'minus')"
|
||||||
|
@mouseout.prevent.stop="onMouseUp($event, 'minus')"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
@@ -19,7 +22,11 @@
|
|||||||
name="la la-plus-circle"
|
name="la la-plus-circle"
|
||||||
class="button"
|
class="button"
|
||||||
:v-ripple="validate(value + step)"
|
:v-ripple="validate(value + step)"
|
||||||
@click="plus"/>
|
@click="plus"
|
||||||
|
@mousedown.prevent.stop="onMouseDown($event, 'plus')"
|
||||||
|
@mouseup.prevent.stop="onMouseUp($event, 'plus')"
|
||||||
|
@mouseout.prevent.stop="onMouseUp($event, 'plus')"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,6 +36,8 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Component from 'vue-class-component';
|
import Component from 'vue-class-component';
|
||||||
|
|
||||||
|
import * as utils from '../../share/utils';
|
||||||
|
|
||||||
const NumInputProps = Vue.extend({
|
const NumInputProps = Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
value: Number,
|
value: Number,
|
||||||
@@ -84,6 +93,33 @@ class NumInput extends NumInputProps {
|
|||||||
if (this.validate(newValue))
|
if (this.validate(newValue))
|
||||||
this.filteredValue = newValue;
|
this.filteredValue = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMouseDown(event, way) {
|
||||||
|
this.startClickRepeat = true;
|
||||||
|
this.clickRepeat = false;
|
||||||
|
|
||||||
|
if (event.button == 0) {
|
||||||
|
(async() => {
|
||||||
|
await utils.sleep(300);
|
||||||
|
if (this.startClickRepeat) {
|
||||||
|
this.clickRepeat = true;
|
||||||
|
while (this.clickRepeat) {
|
||||||
|
if (way == 'plus') {
|
||||||
|
this.plus();
|
||||||
|
} else {
|
||||||
|
this.minus();
|
||||||
|
}
|
||||||
|
await utils.sleep(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseUp() {
|
||||||
|
this.startClickRepeat = false;
|
||||||
|
this.clickRepeat = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user