Skip to content

Commit 849a8ca

Browse files
committed
fix(slider): slide the right thumb when in collision
slide the right thumb when in collision and release the captured pointer event Closes #5762
1 parent cb16744 commit 849a8ca

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ export class IgxSliderComponent implements
657657
* @hidden
658658
*/
659659
@HostListener('pointerdown', ['$event'])
660-
public onPointerDown($event) {
660+
public onPointerDown($event: PointerEvent) {
661661
this.findClosestThumb($event);
662662

663663
if (!this.thumbTo.isActive && this.thumbFrom === undefined) {
@@ -680,6 +680,9 @@ export class IgxSliderComponent implements
680680
return;
681681
}
682682

683+
const activeThumb = this.thumbTo.isActive ? this.thumbTo : this.thumbTo;
684+
activeThumb.nativeElement.releasePointerCapture($event.pointerId);
685+
683686
this.hideSliderIndicators();
684687
}
685688

@@ -925,7 +928,7 @@ export class IgxSliderComponent implements
925928
* @hidden
926929
*/
927930
public onTap($event) {
928-
this.update($event.srcEvent.clientX);
931+
// this.update($event.srcEvent.clientX);
929932
}
930933
/**
931934
*
@@ -1006,9 +1009,9 @@ export class IgxSliderComponent implements
10061009
return value;
10071010
}
10081011

1009-
private findClosestThumb(event) {
1012+
private findClosestThumb(event: PointerEvent) {
10101013
if (this.isRange) {
1011-
this.closestHandle(event.clientX);
1014+
this.closestHandle(event);
10121015
} else {
10131016
this.thumbTo.nativeElement.focus();
10141017
}
@@ -1086,15 +1089,19 @@ export class IgxSliderComponent implements
10861089
this.updateTrack();
10871090
}
10881091

1089-
private closestHandle(mouseX) {
1092+
private closestHandle(event: PointerEvent) {
10901093
const fromOffset = this.thumbFrom.nativeElement.offsetLeft + this.thumbFrom.nativeElement.offsetWidth / 2;
10911094
const toOffset = this.thumbTo.nativeElement.offsetLeft + this.thumbTo.nativeElement.offsetWidth / 2;
1092-
const xPointer = mouseX - this._el.nativeElement.getBoundingClientRect().left;
1095+
const xPointer = event.clientX - this._el.nativeElement.getBoundingClientRect().left;
10931096
const match = this.closestTo(xPointer, [fromOffset, toOffset]);
10941097

1095-
if (match === fromOffset) {
1098+
if (fromOffset === toOffset && toOffset < xPointer) {
1099+
this.thumbTo.nativeElement.focus();
1100+
} else if (fromOffset === toOffset && toOffset > xPointer ) {
10961101
this.thumbFrom.nativeElement.focus();
1097-
} else if (match === toOffset) {
1102+
} else if (match === fromOffset) {
1103+
this.thumbFrom.nativeElement.focus();
1104+
} else {
10981105
this.thumbTo.nativeElement.focus();
10991106
}
11001107
}

0 commit comments

Comments
 (0)