Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/lib/slider/slider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,17 @@ describe('MdSlider', () => {
expect(ticksElement.style.transform).toContain('translateX(9%)');
expect(ticksContainerElement.style.transform).toBe('translateX(-9%)');
});

it('should be able to reset the tick interval after it has been set', () => {
expect(sliderNativeElement.classList)
.toContain('mat-slider-has-ticks', 'Expected element to have ticks initially.');

fixture.componentInstance.tickInterval = null;
fixture.detectChanges();

expect(sliderNativeElement.classList)
.not.toContain('mat-slider-has-ticks', 'Expected element not to have ticks after reset.');
});
});

describe('slider with thumb label', () => {
Expand Down Expand Up @@ -1248,10 +1259,12 @@ class SliderWithStep {
class SliderWithAutoTickInterval { }

@Component({
template: `<md-slider step="3" tickInterval="6"></md-slider>`,
template: `<md-slider step="3" [tickInterval]="tickInterval"></md-slider>`,
styles: [styles],
})
class SliderWithSetTickInterval { }
class SliderWithSetTickInterval {
tickInterval = 6;
}

@Component({
template: `<md-slider thumbLabel></md-slider>`,
Expand Down
10 changes: 8 additions & 2 deletions src/lib/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ export class MdSlider implements ControlValueAccessor {
*/
@Input()
get tickInterval() { return this._tickInterval; }
set tickInterval(v) {
this._tickInterval = (v == 'auto') ? v : coerceNumberProperty(v, <number>this._tickInterval);
set tickInterval(value) {
if (value === 'auto') {
this._tickInterval = 'auto';
} else if (typeof value === 'number' || typeof value === 'string') {
this._tickInterval = coerceNumberProperty(value, this._tickInterval as number);
} else {
this._tickInterval = 0;
}
}

/** @deprecated */
Expand Down