Skip to content

Commit dae31bb

Browse files
authored
Merge pull request #13471 from IgniteUI/slider-13403
fix(slider): properly adjusting bounds #13403
2 parents 87a5ca4 + 1595907 commit dae31bb

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

projects/igniteui-angular/src/lib/slider/slider.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ describe('IgxSlider', () => {
447447
});
448448
});
449449

450-
it('should switch from lower to upper thumb and vice versa when the lower value is equal to the upper one', () => {
450+
// K.D. Removing this functionality because of 0 benefit and lots of issues.
451+
xit('should switch from lower to upper thumb and vice versa when the lower value is equal to the upper one', () => {
451452
slider.value = {
452453
lower: 60,
453454
upper: 60

projects/igniteui-angular/src/lib/slider/slider.component.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ export class IgxSliderComponent implements
891891
const adjustedValue = this.valueInRange(value, this.lowerBound, this.upperBound);
892892
if (this._lowerValue !== adjustedValue) {
893893
this._lowerValue = adjustedValue;
894+
this.lowerValueChange.emit(this._lowerValue);
894895
this.value = { lower: this._lowerValue, upper: this._upperValue };
895896
}
896897
}
@@ -929,6 +930,7 @@ export class IgxSliderComponent implements
929930
const adjustedValue = this.valueInRange(value, this.lowerBound, this.upperBound);
930931
if (this._upperValue !== adjustedValue) {
931932
this._upperValue = adjustedValue;
933+
this.upperValueChange.emit(this._upperValue);
932934
this.value = { lower: this._lowerValue, upper: this._upperValue };
933935
}
934936
}
@@ -1124,28 +1126,26 @@ export class IgxSliderComponent implements
11241126

11251127
if (this.isRange) {
11261128
if (thumbType === SliderHandle.FROM) {
1127-
const newLower = this.lowerValue + value;
1128-
if (newLower >= this.lowerBound && newLower <= this.upperValue) {
1129-
this._lowerValue = newLower;
1130-
this.lowerValueChange.emit(this._lowerValue);
1129+
if (this.lowerValue + value > this.upperValue) {
1130+
this.upperValue = this.lowerValue + value;
11311131
}
1132+
this.lowerValue += value;
11321133
} else {
1133-
const newUpper = this.upperValue + value;
1134-
if (newUpper <= this.upperBound && newUpper >= this.lowerValue) {
1135-
this._upperValue = newUpper;
1136-
this.upperValueChange.emit(this._upperValue);
1134+
if (this.upperValue + value < this.lowerValue) {
1135+
this.lowerValue = this.upperValue + value;
11371136
}
1137+
this.upperValue += value;
11381138
}
11391139

11401140
const newVal: IRangeSliderValue = {
1141-
lower: this._lowerValue,
1142-
upper: this._upperValue
1141+
lower: this.lowerValue,
1142+
upper: this.upperValue
11431143
}
11441144

11451145
// Swap the thumbs if a collision appears.
1146-
if (newVal.lower == newVal.upper) {
1147-
this.toggleThumb();
1148-
}
1146+
// if (newVal.lower == newVal.upper) {
1147+
// this.toggleThumb();
1148+
// }
11491149

11501150
this.value = newVal;
11511151

@@ -1237,11 +1237,11 @@ export class IgxSliderComponent implements
12371237
return this._el.nativeElement.getBoundingClientRect().width / (this.maxValue - this.minValue) * this.step;
12381238
}
12391239

1240-
private toggleThumb() {
1241-
return this.thumbFrom.isActive ?
1242-
this.thumbTo.nativeElement.focus() :
1243-
this.thumbFrom.nativeElement.focus();
1244-
}
1240+
// private toggleThumb() {
1241+
// return this.thumbFrom.isActive ?
1242+
// this.thumbTo.nativeElement.focus() :
1243+
// this.thumbFrom.nativeElement.focus();
1244+
// }
12451245

12461246
private valueInRange(value, min = 0, max = 100) {
12471247
return Math.max(Math.min(value, max), min);

0 commit comments

Comments
 (0)