Files
PhotonVision/New client/chameleon-client/src/components/cv-range-slider.vue
2019-10-18 16:48:08 +03:00

64 lines
2.2 KiB
Vue

<template>
<div>
<v-row dense align="center">
<v-col :cols="2">
<span>{{name}}</span>
</v-col>
<v-col :cols="10">
<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 :value="localValue[0]" :max="max" :min="min" @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 :value="localValue[1]" :max="max" :min="min" @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>
</v-row>
</div>
</template>
<script>
export default {
name: 'RangeSlider',
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:{
localValue:{
get(){
return this.value;
},
set(value){
this.$emit('input',value)
}
}
}
}
</script>
<style lang="" scoped>
</style>