@@ -47,7 +47,7 @@ export class MdSlider implements AfterContentInit {
47
47
/** The percentage of the slider that coincides with the value. */
48
48
private _percent : number = 0 ;
49
49
50
- /** The values at which the thumb will snap to . */
50
+ /** The values at which the thumb will snap. */
51
51
@Input ( ) step : number = 1 ;
52
52
53
53
/**
@@ -118,8 +118,7 @@ export class MdSlider implements AfterContentInit {
118
118
*/
119
119
ngAfterContentInit ( ) {
120
120
this . _sliderDimensions = this . _renderer . getSliderDimensions ( ) ;
121
- this . updatePercentFromValue ( ) ;
122
- this . _renderer . updateThumbAndFillPosition ( this . _percent , this . _sliderDimensions . width ) ;
121
+ this . snapToValue ( ) ;
123
122
}
124
123
125
124
/** TODO: internal */
@@ -132,10 +131,7 @@ export class MdSlider implements AfterContentInit {
132
131
this . isDragging = false ;
133
132
this . _renderer . addFocus ( ) ;
134
133
this . updateValueFromPosition ( event . clientX ) ;
135
-
136
- // Once the click is over the thumb has to snap to its new physical location.
137
- this . updatePercentFromValue ( ) ;
138
- this . _renderer . updateThumbAndFillPosition ( this . _percent , this . _sliderDimensions . width ) ;
134
+ this . snapToValue ( ) ;
139
135
}
140
136
141
137
/** TODO: internal */
@@ -165,9 +161,7 @@ export class MdSlider implements AfterContentInit {
165
161
/** TODO: internal */
166
162
onDragEnd ( ) {
167
163
this . isDragging = false ;
168
- // Once the drag is over the thumb has to snap to its new physical location.
169
- this . updatePercentFromValue ( ) ;
170
- this . _renderer . updateThumbAndFillPosition ( this . _percent , this . _sliderDimensions . width ) ;
164
+ this . snapToValue ( ) ;
171
165
}
172
166
173
167
/** TODO: internal */
@@ -211,6 +205,15 @@ export class MdSlider implements AfterContentInit {
211
205
this . _renderer . updateThumbAndFillPosition ( this . _percent , this . _sliderDimensions . width ) ;
212
206
}
213
207
208
+ /**
209
+ * Snaps the thumb to the current value.
210
+ * Called after a click or drag event is over.
211
+ */
212
+ snapToValue ( ) {
213
+ this . updatePercentFromValue ( ) ;
214
+ this . _renderer . updateThumbAndFillPosition ( this . _percent , this . _sliderDimensions . width ) ;
215
+ }
216
+
214
217
/**
215
218
* Return a number between two numbers.
216
219
*/
0 commit comments