Skip to content

Commit dbe7caa

Browse files
committed
Move shared vertical centering logic into a function
1 parent 9ce5361 commit dbe7caa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/slider/slider.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ $slider-off-color: rgba(black, 0.26);
1515
$slider-focused-color: rgba(black, 0.38);
1616
$slider-disabled-color: rgba(black, 0.26);
1717

18+
@function center-vertically($outerHeight, $innerHeight) {
19+
@return ($outerHeight / 2) - ($innerHeight / 2);
20+
}
21+
1822
@mixin slider-thumb-position($width: $slider-thumb-width, $height: $slider-thumb-height) {
1923
position: absolute;
20-
top: ($slider-size / 2) - ($height / 2);
24+
top: center-vertically($slider-size, $height);
2125
width: $width;
2226
height: $height;
2327
border-radius: max($width, $height);
@@ -53,7 +57,7 @@ md-slider *::after {
5357
.md-slider-track-container {
5458
width: 100%;
5559
position: absolute;
56-
top: ($slider-size / 2) - ($slider-track-height) / 2;
60+
top: center-vertically($slider-size, $slider-track-height);
5761
height: $slider-track-height;
5862
}
5963

0 commit comments

Comments
 (0)