Skip to content

Commit

Permalink
Merge pull request #2307 from tugcekucukoglu/range
Browse files Browse the repository at this point in the history
Fixed #2074 - Range slider get stuck when both handle on max value
  • Loading branch information
tugcekucukoglu authored Mar 11, 2022
2 parents 22721e8 + 971b6b2 commit e249314
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/slider/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e249314

Please sign in to comment.