added vuex to range slider

This commit is contained in:
ori agranat
2019-03-27 23:23:01 +02:00
parent 9a2232974a
commit b86af0abea
2 changed files with 17 additions and 12 deletions

View File

@@ -1,8 +1,8 @@
<template>
<div id="Threshold">
<chrange class="spacing" title="Hue" :parentData="$store.getters.hue" @input="onChange('hue',$event)"></chrange>
<chrange class="spacing" title="Saturation" :parentData="$store.getters.saturation" @input="onChange('saturation',$event)"></chrange>
<chrange class="spacing" title="Value" :parentData="$store.getters.value" @input="onChange('value',$event)"></chrange>
<chrange class="spacing" title="Hue" Xkey="hue"></chrange>
<chrange class="spacing" title="Saturation" Xkey="saturation"></chrange>
<chrange class="spacing" title="Value" Xkey="value"></chrange>
</div>
</template>
@@ -20,9 +20,6 @@ import chselect from './ch-select.vue'
chselect
},
methods:{
onChange: function(key,event) {
this.$store.commit(key, event);
}
}
}

View File

@@ -19,20 +19,28 @@
<script>
export default {
name: 'ch-range',
props:['title','parentData'],
props:{title:'',
Xkey:''
},
data() {
return {
value:0
value
}
},
methods: {
handleInput() {
this.$emit('input',this.value);
this.$socket.sendObj({[this.title]:this.value});
this.$socket.sendObj({[this.Xkey]:this.value});
}
},
beforeMount () {
this.value = this.parentData
computed:{
value:{
get:function(){
return this.$store.state[this.Xkey];
},
set:function(value){
this.$store.commit(this.Xkey,value);
}
}
}
}
</script>