fixed double emit bug

This commit is contained in:
ori agranat
2019-10-11 01:18:14 +03:00
parent c841f3d456
commit 0b0798ff51
5 changed files with 41 additions and 10 deletions

View File

@@ -5,13 +5,13 @@
<span>{{name}}</span>
</v-col>
<v-col :cols="10">
<v-range-slider v-model="localValue" :max="max" :min="min" hide-details class="align-center" dark color="#4baf62" :step="step">
<v-range-slider :value="localValue" @input="handleInput" :max="max" :min="min" hide-details class="align-center" dark color="#4baf62" :step="step">
<template v-slot:prepend>
<v-text-field v-model="localValue[0]" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
<v-text-field :value="localValue[0]" @input="handleChange" @focus="prependFocused = true" @blur="prependFocused = false" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
</template>
<template v-slot:append>
<v-text-field v-model="localValue[1]" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
<v-text-field :value="localValue[1]" @input="handleChange" @focus="appendFocused = true" @blur="appendFocused = false" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
</template>
</v-range-slider>
</v-col>
@@ -25,6 +25,25 @@
props:['name','min','max','value','step'],
data() {
return {
prependFocused:false,
appendFocused:false
}
},
methods:{
handleChange(val){
let i = 0;
if(this.prependFocused === false && this.appendFocused === true){
i = 1;
}
if(this.prependFocused || this.appendFocused){
this.$set(this.localValue,i,val);
}
},
handleInput(val){
if(!this.prependFocused || !this.appendFocused){
this.localValue = val;
}
}
},
computed:{

View File

@@ -5,9 +5,9 @@
<span>{{name}}</span>
</v-col>
<v-col :cols="10">
<v-slider v-model="localValue" dark class="align-center" :max="max" :min="min" hide-details color="#4baf62" :step="step">
<v-slider :value="localValue" @input="handleInput" dark class="align-center" :max="max" :min="min" hide-details color="#4baf62" :step="step">
<template v-slot:append>
<v-text-field dark v-model="localValue" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
<v-text-field dark :value="localValue" @input="handleChange" @focus="isFocused = true" @blur="isFocused = false" class="mt-0 pt-0" hide-details single-line type="number" style="width: 50px" :step="step"></v-text-field>
</template>
</v-slider>
</v-col>
@@ -21,10 +21,20 @@
props:['min','max','name','value','step'],
data() {
return {
isFocused:false
}
},
methods:{
handleChange(val){
if(this.isFocused){
this.localValue = parseFloat(val);
}
},
handleInput(val){
if(!this.isFocused){
this.localValue = val;
}
}
},
computed:{
localValue:{

View File

@@ -91,6 +91,9 @@ import CVicon from '../components/cv-icon'
CVicon
},
methods:{
test(value){
console.log(value)
}
},
data() {
return {

View File

@@ -23,10 +23,7 @@ import CVselect from '../../components/cv-select'
}
},
methods:{
// handleInput(key,val){
// let msg = this.$msgPack().encode({key,val});
// this.$socket.send(msg);
// }
},
computed:{}
}

View File

@@ -23,6 +23,8 @@ import CVswitch from '../../components/cv-switch'
}
},
computed:{
},
methods:{
}
}
</script>