Skip to content

Commit 8efb5d8

Browse files
committed
Add comments
1 parent b0ee88a commit 8efb5d8

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/components/slider/slider.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ $md-slider-disabled-color: rgba(black, 0.26);
3131
@mixin slider-thumb-position($width: $md-slider-thumb-size, $height: $md-slider-thumb-size) {
3232
position: absolute;
3333
top: center-vertically($md-slider-thickness, $height);
34+
// This makes it so that the center of the thumb aligns with where the click was.
35+
// This is not affected by the movement of the thumb.
3436
left: (-$width / 2);
3537
width: $width;
3638
height: $height;

src/components/slider/slider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ export class MdSlider implements AfterContentInit {
203203
this._percent = this.clamp((pos - offset) / size);
204204
let exactValue = this.min + (this._percent * (this.max - this.min));
205205

206+
// This calculation finds the closest step by finding the closest whole number divisible by the
207+
// step relative to the min.
206208
this.value = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
207209
this._renderer.updateThumbAndFillPosition(this._percent, this._sliderDimensions.width);
208210
}

0 commit comments

Comments
 (0)