@@ -5,12 +5,12 @@ import {
55 ViewChild ,
66 TemplateRef ,
77 ContentChild ,
8- AfterContentInit ,
98 OnDestroy ,
109 HostListener ,
1110 ViewChildren ,
1211 QueryList ,
13- ChangeDetectorRef
12+ ChangeDetectorRef ,
13+ AfterContentChecked
1414} from '@angular/core' ;
1515import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
1616import { EditorProvider } from '../core/edit-provider' ;
@@ -63,7 +63,7 @@ export class IgxSliderComponent implements
6363 EditorProvider ,
6464 OnInit ,
6565 AfterViewInit ,
66- AfterContentInit ,
66+ AfterContentChecked ,
6767 OnDestroy {
6868
6969 // Limit handle travel zone
@@ -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 ) {
@@ -668,6 +668,7 @@ export class IgxSliderComponent implements
668668 activeThumb . nativeElement . setPointerCapture ( $event . pointerId ) ;
669669 this . showSliderIndicators ( ) ;
670670
671+ $event . preventDefault ( ) ;
671672 }
672673
673674
@@ -680,6 +681,9 @@ export class IgxSliderComponent implements
680681 return ;
681682 }
682683
684+ const activeThumb = this . thumbTo . isActive ? this . thumbTo : this . thumbTo ;
685+ activeThumb . nativeElement . releasePointerCapture ( $event . pointerId ) ;
686+
683687 this . hideSliderIndicators ( ) ;
684688 }
685689
@@ -709,14 +713,6 @@ export class IgxSliderComponent implements
709713 this . hideSliderIndicators ( ) ;
710714 }
711715
712- /**
713- * @hidden
714- */
715- @HostListener ( 'tap' , [ '$event' ] )
716- public onTapListener ( $event ) {
717- this . onTap ( $event ) ;
718- }
719-
720716 /**
721717 *Returns whether the `IgxSliderComponent` type is RANGE.
722718 *```typescript
@@ -874,7 +870,7 @@ export class IgxSliderComponent implements
874870 /**
875871 * @hidden
876872 */
877- public ngAfterContentInit ( ) {
873+ public ngAfterContentChecked ( ) {
878874 // Calculates the distance between every step in pixels.
879875 this . stepDistance = this . calculateStepDistance ( ) ;
880876 }
@@ -920,13 +916,6 @@ export class IgxSliderComponent implements
920916 return this . isRange ? this . thumbFrom . nativeElement : this . thumbTo . nativeElement ;
921917 }
922918
923- /**
924- *
925- * @hidden
926- */
927- public onTap ( $event ) {
928- this . update ( $event . srcEvent . clientX ) ;
929- }
930919 /**
931920 *
932921 * @hidden
@@ -1006,9 +995,9 @@ export class IgxSliderComponent implements
1006995 return value ;
1007996 }
1008997
1009- private findClosestThumb ( event ) {
998+ private findClosestThumb ( event : PointerEvent ) {
1010999 if ( this . isRange ) {
1011- this . closestHandle ( event . clientX ) ;
1000+ this . closestHandle ( event ) ;
10121001 } else {
10131002 this . thumbTo . nativeElement . focus ( ) ;
10141003 }
@@ -1086,15 +1075,19 @@ export class IgxSliderComponent implements
10861075 this . updateTrack ( ) ;
10871076 }
10881077
1089- private closestHandle ( mouseX ) {
1078+ private closestHandle ( event : PointerEvent ) {
10901079 const fromOffset = this . thumbFrom . nativeElement . offsetLeft + this . thumbFrom . nativeElement . offsetWidth / 2 ;
10911080 const toOffset = this . thumbTo . nativeElement . offsetLeft + this . thumbTo . nativeElement . offsetWidth / 2 ;
1092- const xPointer = mouseX - this . _el . nativeElement . getBoundingClientRect ( ) . left ;
1081+ const xPointer = event . clientX - this . _el . nativeElement . getBoundingClientRect ( ) . left ;
10931082 const match = this . closestTo ( xPointer , [ fromOffset , toOffset ] ) ;
10941083
1095- if ( match === fromOffset ) {
1084+ if ( fromOffset === toOffset && toOffset < xPointer ) {
1085+ this . thumbTo . nativeElement . focus ( ) ;
1086+ } else if ( fromOffset === toOffset && toOffset > xPointer ) {
1087+ this . thumbFrom . nativeElement . focus ( ) ;
1088+ } else if ( match === fromOffset ) {
10961089 this . thumbFrom . nativeElement . focus ( ) ;
1097- } else if ( match === toOffset ) {
1090+ } else {
10981091 this . thumbTo . nativeElement . focus ( ) ;
10991092 }
11001093 }
0 commit comments