Skip to content

Commit 70b74b5

Browse files
committed
Value should snap to the edges of the slider
1 parent 8efb5d8 commit 70b74b5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/slider/slider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ export class MdSlider implements AfterContentInit {
205205

206206
// This calculation finds the closest step by finding the closest whole number divisible by the
207207
// step relative to the min.
208-
this.value = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
208+
let closestValue = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
209+
// The value needs to snap to the min and max.
210+
this.value = this.clamp(closestValue, this.min, this.max);
209211
this._renderer.updateThumbAndFillPosition(this._percent, this._sliderDimensions.width);
210212
}
211213

src/demo-app/slider/slider-demo.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ <h1>Slider with set value</h1>
2323

2424
<h1>Slider with step defined</h1>
2525
<section class="demo-section">
26-
<md-slider step="25"></md-slider>
26+
<md-slider min="1" max="100" step="20" #slider5></md-slider>
27+
{{slider5.value}}
2728
</section>

0 commit comments

Comments
 (0)