Skip to content

Commit 5e36d17

Browse files
committed
Simplify tick interval input
1 parent 400d14d commit 5e36d17

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/components/slider/slider.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class MdSlider implements AfterContentInit {
6060
* How often to show ticks. Relative to the step so that a tick always appears on a step.
6161
* Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
6262
*/
63-
private _tickInterval: 'auto' | number;
63+
@Input('tick-interval') private _tickInterval: 'auto' | number;
6464

6565
/**
6666
* Whether or not the thumb is sliding.
@@ -108,19 +108,6 @@ export class MdSlider implements AfterContentInit {
108108
this._max = Number(v);
109109
}
110110

111-
@Input('tick-interval')
112-
get tickInterval() {
113-
return this._tickInterval;
114-
}
115-
116-
set tickInterval(v: 'auto' | number) {
117-
if (v == 'auto') {
118-
this._tickInterval = v;
119-
} else {
120-
this._tickInterval = Number(v);
121-
}
122-
}
123-
124111
@Input()
125112
@HostBinding('attr.aria-valuenow')
126113
get value() {
@@ -246,9 +233,9 @@ export class MdSlider implements AfterContentInit {
246233
* number or 'auto', nothing happens.
247234
*/
248235
private _calculateTickSeparation() {
249-
if (this.tickInterval == 'auto') {
236+
if (this._tickInterval == 'auto') {
250237
this._calculateAutoTickSeparation();
251-
} else if (typeof this.tickInterval == 'number') {
238+
} else if (Number(this._tickInterval)) {
252239
this._calculateTickSeparationFromInterval();
253240
}
254241
}
@@ -285,7 +272,7 @@ export class MdSlider implements AfterContentInit {
285272
*/
286273
private _calculateTickSeparationFromInterval() {
287274
// Force tickInterval to be a number so it can be used in calculations.
288-
let interval: number = <number> this.tickInterval;
275+
let interval: number = <number> this._tickInterval;
289276
// Calculate the first value a tick will be located at by getting the step at which the interval
290277
// lands and adding that to the min.
291278
let tickValue = (this.step * interval) + this.min;

0 commit comments

Comments
 (0)