Fixed #2074 - Range slider get stuck when both handle on max value

pull/2307/head
Tuğçe Küçükoğlu 2022-03-11 15:40:52 +03:00
parent 22721e81ce
commit 971b6b22a1
1 changed files with 10 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<div :class="containerClass" @click="onBarClick">
<span class="p-slider-range" :style="rangeStyle"></span>
<span v-if="!range" class="p-slider-handle" :style="handleStyle" @touchstart="onDragStart($event)" @touchmove="onDrag($event)" @touchend="onDragEnd($event)" @mousedown="onMouseDown($event)" @keydown="onKeyDown($event)" tabindex="0"
role="slider" :aria-valuemin="min" :aria-valuenow="modelValue" :aria-valuemax="max" :aria-labelledby="ariaLabelledBy"></span>
role="slider" :aria-valuemin="min" :aria-valuenow="modelValue" :aria-valuemax="max" :aria-labelledby="ariaLabelledBy"></span>
<span v-if="range" class="p-slider-handle" :style="rangeStartHandleStyle" @touchstart="onDragStart($event, 0)" @touchmove="onDrag($event)" @touchend="onDragEnd($event)" @mousedown="onMouseDown($event, 0)" @keydown="onKeyDown($event)" tabindex="0"
role="slider" :aria-valuemin="min" :aria-valuenow="modelValue ? modelValue[0] : null" :aria-valuemax="max" :aria-labelledby="ariaLabelledBy"></span>
<span v-if="range" class="p-slider-handle" :style="rangeEndHandleStyle" @touchstart="onDragStart($event, 1)" @touchmove="onDrag($event)" @touchend="onDragEnd($event)" @mousedown="onMouseDown($event, 1)" @keydown="onKeyDown($event, 1)" tabindex="0"
@ -133,10 +133,18 @@ export default {
if (this.disabled) {
return;
}
DomHandler.addClass(this.$el, 'p-slider-sliding');
this.dragging = true;
this.updateDomData();
this.handleIndex = index;
if (this.range && this.modelValue[0] === this.max) {
this.handleIndex = 0;
}
else {
this.handleIndex = index;
}
event.preventDefault();
},
onDrag(event) {