pull/345/head
cagataycivici 2020-06-17 15:39:52 +03:00
commit f325d42591
2 changed files with 22 additions and 21 deletions

View File

@ -209,16 +209,8 @@ export default {
},
spin(event, dir) {
let step = this.step * dir;
let currentValue = this.value || 0;
let newValue = currentValue + step;
if (this.min !== null && newValue < this.min) {
newValue = this.min;
}
if (this.max !== null && newValue > this.max) {
newValue = this.max;
}
let currentValue = this.parseValue(this.$refs.input.$el.value) || 0;
let newValue = this.validateValue(currentValue + step);
this.updateInput(newValue, 'spin');
this.updateModel(event, newValue);
@ -492,16 +484,19 @@ export default {
updateValue(event, valueStr, operation) {
if (valueStr != null) {
let newValue = this.parseValue(valueStr);
let valid = this.isWithinRange(newValue);
if (valid) {
this.updateInput(newValue, operation);
this.updateModel(event, newValue);
}
this.updateInput(newValue, operation);
}
},
isWithinRange(value) {
return value == null || ((this.min == null || value > this.min) && (this.max == null || value < this.max));
validateValue(value) {
if (this.min != null && value < this.min) {
return this.min;
}
if (this.max != null && value > this.max) {
return this.max;
}
return value;
},
updateInput(value, operation) {
let currentLength = this.$refs.input.$el.value.length;
@ -545,6 +540,12 @@ export default {
},
onInputBlur(event) {
this.focused = false;
let newValue = this.validateValue(this.parseValue(this.$refs.input.$el.value));
this.$refs.input.$el.value = this.formatValue(newValue);
this.$refs.input.$el.setAttribute('aria-valuenow', newValue);
this.updateModel(event, newValue);
this.$emit('blur', event);
},
clearTimer() {
@ -714,4 +715,4 @@ export default {
.p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {
width: 100%;
}
</style>
</style>

View File

@ -81,7 +81,7 @@
</div>
<div class="p-field p-col-12 p-md-3">
<label for="temperature">Temperature</label>
<InputNumber id="temperature" v-model="value16" prefix="&uarr; " suffix="℃" :min="0" :max="40" />
<InputNumber id="temperature" v-model="value16" prefix=" " suffix="℃" :min="0" :max="40" />
</div>
</div>
@ -150,4 +150,4 @@ export default {
.layout-content .content-section.implementation > h3 {
font-weight: 600;
}
</style>
</style>