Skip to content

Commit db693aa

Browse files
committed
[GUI] Slider fixes for min and max values
1 parent d19519d commit db693aa

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

GUI/src/components/controls/CtrlSlider.vue

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<span class="ctrlName">{{name}}</span>
66
</div>
77
<div class="slider-container">
8-
<input type="number" :value="displayMin" v-on:change="setMin"/>
8+
<input :value="displayMin" :placeholder="displayMin" v-on:change="setMin"/>
99
<!-- <vue-slider v-model="value" :min="min" :max="max" :interval="interval" /> -->
1010
<vue-slider v-model="value" :data="data" :adsorb="true" @change="putVal"/>
11-
<input type="number" :value="displayMax" v-on:change="setMax" />
11+
<input :value="displayMax" :placeholder="displayMax" v-on:change="setMax" />
1212
</div>
1313
</div>
1414
</template>
@@ -66,14 +66,20 @@ export default {
6666
putVal(keys.join('.'), value);
6767
},
6868
setMin: function (e) {
69-
this.min = parseMath(e.target.value);
70-
this.data = Array.from(Array(101), (_, i) => this.min + (this.max-this.min) / 100 * i);
71-
this.value = this.findNearest(this.data, this.value);
69+
let min = parseMath(e.target.value);
70+
if (min < this.max) {
71+
this.min = min;
72+
this.data = Array.from(Array(101), (_, i) => this.min + (this.max-this.min) / 100 * i);
73+
this.value = this.findNearest(this.data, this.value);
74+
}
7275
},
7376
setMax: function (e) {
74-
this.max = parseMath(e.target.value);
75-
this.data = Array.from(Array(101), (_, i) => this.min + (this.max-this.min) / 100 * i);
76-
this.value = this.findNearest(this.data, this.value);
77+
let max = parseMath(e.target.value);
78+
if (max > this.min) {
79+
this.max = max;
80+
this.data = Array.from(Array(101), (_, i) => this.min + (this.max-this.min) / 100 * i);
81+
this.value = this.findNearest(this.data, this.value);
82+
}
7783
},
7884
deleteCtrl: function() {
7985
// commit a mutation in the store with the relevant information

0 commit comments

Comments
 (0)