Skip to content

Commit

Permalink
bug: fix slider fill as value change
Browse files Browse the repository at this point in the history
  • Loading branch information
milan090 committed Mar 29, 2021
1 parent 444a259 commit be92784
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions components/SimulationControls/SliderInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
:max="max"
:value="value"
:step="step"
@change="handleChange"
:style="{
background: `linear-gradient(to right, #2c5bd1 0%, #2c5bd1 ${valuePercentage}%, #434b5266 ${valuePercentage}%, #434b5266 100%)`,
}"
@change="handleChange"
@input="handleInput"
/>
</div>
</div>
Expand All @@ -27,10 +28,22 @@
export default {
name: "SliderInput",
props: {
name: String,
min: Number,
max: Number,
value: Number,
name: {
default: "Field",
type: String,
},
min: {
default: 0,
type: Number,
},
max: {
type: Number,
default: 10,
},
value: {
type: Number,
default: 5,
},
step: {
type: Number,
default: 0.5,
Expand All @@ -46,6 +59,13 @@ export default {
const newValue = parseFloat(event.target.value);
this.$emit("options-change", this.name, newValue);
},
handleInput(event) {
const target = event.target;
const valuePercentage =
((target.value - this.min) / (this.max - this.min)) * 100;
event.target.style.background = `linear-gradient(to right, #2c5bd1 0%, #2c5bd1 ${valuePercentage}%, #434b5266 ${valuePercentage}%, #434b5266 100%)`;
},
},
};
</script>
Expand Down

1 comment on commit be92784

@vercel
Copy link

@vercel vercel bot commented on be92784 Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.