File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -517,6 +517,17 @@ describe('MdSlider', () => {
517
517
expect ( ticksElement . style . transform ) . toContain ( 'translateX(9%)' ) ;
518
518
expect ( ticksContainerElement . style . transform ) . toBe ( 'translateX(-9%)' ) ;
519
519
} ) ;
520
+
521
+ it ( 'should be able to reset the tick interval after it has been set' , ( ) => {
522
+ expect ( sliderNativeElement . classList )
523
+ . toContain ( 'mat-slider-has-ticks' , 'Expected element to have ticks initially.' ) ;
524
+
525
+ fixture . componentInstance . tickInterval = null ;
526
+ fixture . detectChanges ( ) ;
527
+
528
+ expect ( sliderNativeElement . classList )
529
+ . not . toContain ( 'mat-slider-has-ticks' , 'Expected element not to have ticks after reset.' ) ;
530
+ } ) ;
520
531
} ) ;
521
532
522
533
describe ( 'slider with thumb label' , ( ) => {
@@ -1248,10 +1259,12 @@ class SliderWithStep {
1248
1259
class SliderWithAutoTickInterval { }
1249
1260
1250
1261
@Component ( {
1251
- template : `<md-slider step="3" tickInterval="6 "></md-slider>` ,
1262
+ template : `<md-slider step="3" [ tickInterval]="tickInterval "></md-slider>` ,
1252
1263
styles : [ styles ] ,
1253
1264
} )
1254
- class SliderWithSetTickInterval { }
1265
+ class SliderWithSetTickInterval {
1266
+ tickInterval = 6 ;
1267
+ }
1255
1268
1256
1269
@Component ( {
1257
1270
template : `<md-slider thumbLabel></md-slider>` ,
Original file line number Diff line number Diff line change @@ -164,8 +164,14 @@ export class MdSlider implements ControlValueAccessor {
164
164
*/
165
165
@Input ( )
166
166
get tickInterval ( ) { return this . _tickInterval ; }
167
- set tickInterval ( v ) {
168
- this . _tickInterval = ( v == 'auto' ) ? v : coerceNumberProperty ( v , < number > this . _tickInterval ) ;
167
+ set tickInterval ( value ) {
168
+ if ( value === 'auto' ) {
169
+ this . _tickInterval = 'auto' ;
170
+ } else if ( typeof value === 'number' || typeof value === 'string' ) {
171
+ this . _tickInterval = coerceNumberProperty ( value , this . _tickInterval as number ) ;
172
+ } else {
173
+ this . _tickInterval = 0 ;
174
+ }
169
175
}
170
176
private _tickInterval : 'auto' | number = 0 ;
171
177
You can’t perform that action at this time.
0 commit comments