@@ -139,15 +139,21 @@ export class IgxSliderComponent implements
139
139
private _onChangeCallback : ( _ : any ) => void = noop ;
140
140
private _onTouchedCallback : ( ) => void = noop ;
141
141
142
- @ ViewChild ( 'slider' )
143
- private slider : ElementRef ;
144
-
142
+ /**
143
+ * @hidden
144
+ */
145
145
@ViewChild ( 'track' )
146
146
private track : ElementRef ;
147
147
148
+ /**
149
+ * @hidden
150
+ */
148
151
@ViewChild ( 'ticks' )
149
152
private ticks : ElementRef ;
150
153
154
+ /**
155
+ * @hidden
156
+ */
151
157
@ViewChildren ( IgxSliderThumbComponent )
152
158
private thumbs : QueryList < IgxSliderThumbComponent > = new QueryList < IgxSliderThumbComponent > ( ) ;
153
159
@@ -159,7 +165,14 @@ export class IgxSliderComponent implements
159
165
return this . thumbs . find ( thumb => thumb . type === SliderHandle . TO ) ;
160
166
}
161
167
168
+ /**
169
+ * @hidden
170
+ */
162
171
public stepDistance = this . _step ;
172
+
173
+ /**
174
+ * @hidden
175
+ */
163
176
public onPan : Subject < number > = new Subject < number > ( ) ;
164
177
165
178
/**
@@ -204,6 +217,19 @@ export class IgxSliderComponent implements
204
217
return this . disabled ;
205
218
}
206
219
220
+ /**
221
+ * @hidden
222
+ */
223
+ @HostBinding ( 'class.igx-slider' )
224
+ public slierClass = true ;
225
+
226
+ /**
227
+ * @hidden
228
+ */
229
+ @HostBinding ( 'class.igx-slider--disabled' )
230
+ public get disabledClass ( ) {
231
+ return this . disabled ;
232
+ }
207
233
208
234
/**
209
235
* An @Input property that sets the value of the `id` attribute.
@@ -216,6 +242,20 @@ export class IgxSliderComponent implements
216
242
@Input ( )
217
243
public id = `igx-slider-${ NEXT_ID ++ } ` ;
218
244
245
+ /**
246
+ * An @Input property that gets the type of the `IgxSliderComponent`. The slider can be SliderType.SLIDER(default) or SliderType.RANGE.
247
+ * ```typescript
248
+ * @ViewChild ("slider2")
249
+ * public slider: IgxSliderComponent;
250
+ * ngAfterViewInit(){
251
+ * let type = this.slider.type;
252
+ * }
253
+ */
254
+ @Input ( )
255
+ public get type ( ) {
256
+ return this . _type ;
257
+ }
258
+
219
259
/**
220
260
* An @Input property that sets the type of the `IgxSliderComponent`. The slider can be SliderType.SLIDER(default) or SliderType.RANGE.
221
261
* ```typescript
@@ -225,11 +265,6 @@ export class IgxSliderComponent implements
225
265
* <igx-slider #slider2 [type]="sliderType" [(ngModel)]="rangeValue" [minValue]="0" [maxValue]="100">
226
266
* ```
227
267
*/
228
- @Input ( )
229
- public get type ( ) {
230
- return this . _type ;
231
- }
232
-
233
268
public set type ( type : SliderType ) {
234
269
this . _type = type ;
235
270
@@ -639,17 +674,25 @@ export class IgxSliderComponent implements
639
674
public onValueChange = new EventEmitter < ISliderValueChangeEventArgs > ( ) ;
640
675
641
676
642
- constructor ( private renderer : Renderer2 ) { }
677
+ constructor ( private renderer : Renderer2 , private _el : ElementRef ) { }
678
+
679
+ /**
680
+ * @hidden
681
+ */
682
+ @HostListener ( 'pointerdown' , [ '$event' ] )
683
+ public onPointerDown ( $event ) {
684
+ this . findClosestThumb ( $event ) ;
643
685
644
- @HostListener ( 'pointerdown' )
645
- public onPointerDown ( ) {
646
686
if ( ! this . thumbTo . isActive && this . thumbFrom === undefined ) {
647
687
return ;
648
688
}
649
689
650
690
this . showThumbLabels ( ) ;
651
691
}
652
692
693
+ /**
694
+ * @hidden
695
+ */
653
696
@HostListener ( 'pointerup' )
654
697
public onPointerUp ( ) {
655
698
if ( ! this . thumbTo . isActive && this . thumbFrom === undefined ) {
@@ -659,16 +702,38 @@ export class IgxSliderComponent implements
659
702
this . hideThumbLabels ( ) ;
660
703
}
661
704
705
+ /**
706
+ * @hidden
707
+ */
662
708
@HostListener ( 'focus' )
663
709
public onFocus ( ) {
664
710
this . toggleThumbLabels ( ) ;
665
711
}
666
712
713
+ /**
714
+ * @hidden
715
+ */
667
716
@HostListener ( 'blur' )
668
717
public onBlur ( ) {
669
718
this . hideThumbLabels ( ) ;
670
719
}
671
720
721
+ /**
722
+ * @hidden
723
+ */
724
+ @HostListener ( 'pan' , [ '$event' ] )
725
+ public onPanListener ( $event ) {
726
+ this . update ( $event . srcEvent . clientX )
727
+ }
728
+
729
+ /**
730
+ * @hidden
731
+ */
732
+ @HostListener ( 'tap' , [ '$event' ] )
733
+ public onTapListener ( $event ) {
734
+ this . onTap ( $event ) ;
735
+ }
736
+
672
737
/**
673
738
*Returns whether the `IgxSliderComponent` type is RANGE.
674
739
*```typescript
@@ -889,6 +954,9 @@ export class IgxSliderComponent implements
889
954
this . _onTouchedCallback ( ) ;
890
955
}
891
956
957
+ /**
958
+ * @hidden
959
+ */
892
960
public thumbChanged ( value : number , thumbType : number ) {
893
961
const oldValue = this . value ;
894
962
@@ -922,7 +990,14 @@ export class IgxSliderComponent implements
922
990
}
923
991
}
924
992
925
- public swapThumb ( value : IRangeSliderValue ) {
993
+ /**
994
+ * @hidden
995
+ */
996
+ public onThumbChange ( ) {
997
+ this . toggleThumbLabels ( ) ;
998
+ }
999
+
1000
+ private swapThumb ( value : IRangeSliderValue ) {
926
1001
if ( this . thumbFrom . isActive ) {
927
1002
value . upper = this . upperValue ;
928
1003
value . lower = this . upperValue ;
@@ -936,10 +1011,7 @@ export class IgxSliderComponent implements
936
1011
return value ;
937
1012
}
938
1013
939
- /**
940
- * @hidden
941
- */
942
- public findClosestThumb ( event ) {
1014
+ private findClosestThumb ( event ) {
943
1015
if ( this . isRange ) {
944
1016
this . closestHandle ( event . clientX ) ;
945
1017
} else {
@@ -951,10 +1023,6 @@ export class IgxSliderComponent implements
951
1023
event . preventDefault ( ) ;
952
1024
}
953
1025
954
- public onThumbChange ( ) {
955
- this . toggleThumbLabels ( ) ;
956
- }
957
-
958
1026
private updateLowerBoundAndMinTravelZone ( ) {
959
1027
this . lowerBound = this . minValue ;
960
1028
this . _pMin = 0 ;
@@ -976,7 +1044,7 @@ export class IgxSliderComponent implements
976
1044
}
977
1045
978
1046
private calculateStepDistance ( ) {
979
- return this . slider . nativeElement . getBoundingClientRect ( ) . width / ( this . maxValue - this . minValue ) * this . step ;
1047
+ return this . _el . nativeElement . getBoundingClientRect ( ) . width / ( this . maxValue - this . minValue ) * this . step ;
980
1048
}
981
1049
982
1050
private toggleThumb ( ) {
@@ -1027,7 +1095,7 @@ export class IgxSliderComponent implements
1027
1095
private closestHandle ( mouseX ) {
1028
1096
const fromOffset = this . thumbFrom . nativeElement . offsetLeft + this . thumbFrom . nativeElement . offsetWidth / 2 ;
1029
1097
const toOffset = this . thumbTo . nativeElement . offsetLeft + this . thumbTo . nativeElement . offsetWidth / 2 ;
1030
- const xPointer = mouseX - this . slider . nativeElement . getBoundingClientRect ( ) . left ;
1098
+ const xPointer = mouseX - this . _el . nativeElement . getBoundingClientRect ( ) . left ;
1031
1099
const match = this . closestTo ( xPointer , [ fromOffset , toOffset ] ) ;
1032
1100
1033
1101
if ( match === fromOffset ) {
0 commit comments