diff --git a/client/components/share/NumInput.vue b/client/components/share/NumInput.vue index cb9b4c3d..ebc1cdc9 100644 --- a/client/components/share/NumInput.vue +++ b/client/components/share/NumInput.vue @@ -12,6 +12,9 @@ class="button" :v-ripple="validate(value - step)" @click="minus" + @mousedown.prevent.stop="onMouseDown($event, 'minus')" + @mouseup.prevent.stop="onMouseUp($event, 'minus')" + @mouseout.prevent.stop="onMouseUp($event, 'minus')" /> @@ -29,6 +36,8 @@ import Vue from 'vue'; import Component from 'vue-class-component'; +import * as utils from '../../share/utils'; + const NumInputProps = Vue.extend({ props: { value: Number, @@ -84,6 +93,33 @@ class NumInput extends NumInputProps { if (this.validate(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; + } } //-----------------------------------------------------------------------------