@@ -7,148 +7,129 @@ $md-slider-thickness: 48px !default;
7
7
$md-slider-min-size : 128px !default ;
8
8
$md-slider-padding : 8px !default ;
9
9
10
- $md-slider-track-height : 2px !default ;
10
+ $md-slider-track-thickness : 2px !default ;
11
11
$md-slider-thumb-size : 20px !default ;
12
12
13
13
$md-slider-thumb-default-scale : 0.7 !default ;
14
14
$md-slider-thumb-focus-scale : 1 !default ;
15
15
16
- $md-slider-thumb-arrow-height : 16px !default ;
17
- $md-slider-thumb-arrow-width : 28px !default ;
16
+ $md-slider-thumb-arrow-gap : 12px !default ;
18
17
19
18
$md-slider-thumb-label-size : 28px !default ;
20
- // The thumb has to be moved down so that it appears right over the slider track when visible and
21
- // on the slider track when not.
22
- $md-slider-thumb-label-top : ($md-slider-thickness / 2 ) -
23
- ($md-slider-thumb-default-scale * $md-slider-thumb-size / 2 ) - $md-slider-thumb-label-size -
24
- $md-slider-thumb-arrow-height + 10px !default ;
25
19
26
- // Uses a container height and an item height to center an item vertically within the container.
27
- @function center-vertically ($containerHeight , $itemHeight ) {
28
- @return ($containerHeight / 2 ) - ($itemHeight / 2 );
29
- }
20
+ $md-slider-tick-color : rgba (0 , 0 , 0 , .6 ) !default ;
21
+ $md-slider-tick-size : 2px !default ;
30
22
31
- // Positions the thumb based on its width and height.
32
- @mixin slider-thumb-position ($width : $md-slider-thumb-size , $height : $md-slider-thumb-size ) {
33
- position : absolute ;
34
- top : center-vertically ($md-slider-thickness , $height );
35
- // This makes it so that the center of the thumb aligns with where the click was.
36
- // This is not affected by the movement of the thumb.
37
- left : (- $width / 2 );
38
- width : $width ;
39
- height : $height ;
40
- border-radius : max ($width , $height );
41
- }
42
23
43
24
md-slider {
25
+ display : inline-block ;
26
+ box-sizing : border-box ;
27
+ position : relative ;
44
28
height : $md-slider-thickness ;
45
29
min-width : $md-slider-min-size ;
46
- position : relative ;
47
- padding : 0 ;
48
- display : inline-block ;
30
+ padding : $md-slider-padding ;
49
31
outline : none ;
50
32
vertical-align : middle ;
51
33
}
52
34
53
- md-slider * ,
54
- md-slider * ::after {
55
- box-sizing : border-box ;
35
+ .md-slider-track {
36
+ display : flex ;
37
+ flex-grow : 1 ;
38
+ align-items : center ;
39
+ position : relative ;
40
+ top : ($md-slider-thickness - $md-slider-track-thickness ) / 2 - $md-slider-padding ;
41
+ height : $md-slider-track-thickness ;
42
+ transition : box-shadow $swift-ease-out-duration $swift-ease-out-timing-function ;
56
43
}
57
44
58
- // Exists in order to pad the slider and keep everything positioned correctly.
59
- // Cannot be merged with the .md-slider-container.
60
- .md-slider-wrapper {
61
- width : 100% ;
62
- height : 100% ;
63
- padding-left : $md-slider-padding ;
64
- padding-right : $md-slider-padding ;
45
+ .md-slider-has-ticks.md-slider-active .md-slider-track ,
46
+ .md-slider-has-ticks :hover .md-slider-track {
47
+ box-shadow : inset (-2 * $md-slider-tick-size ) 0 0 (- $md-slider-tick-size ) $md-slider-tick-color ;
65
48
}
66
49
67
-
68
- // Holds the isActive and isSliding classes as well as helps with positioning the children.
69
- // Cannot be merged with .md-slider-wrapper.
70
- .md-slider-container {
71
- position : relative ;
50
+ .md-slider-track-fill {
51
+ flex : 0 0 50% ;
52
+ height : $md-slider-track-thickness ;
53
+ transition : flex-basis $swift-ease-out-duration $swift-ease-out-timing-function ;
72
54
}
73
55
74
- .md-slider-track-container {
75
- width : 100% ;
76
- position : absolute ;
77
- top : center-vertically ($md-slider-thickness , $md-slider-track-height );
78
- height : $md-slider-track-height ;
56
+ .md-slider-sliding .md-slider-track-fill {
57
+ transition : none ;
79
58
}
80
59
81
- .md-slider-track {
60
+ .md-slider-ticks-container {
82
61
position : absolute ;
83
- left : 0 ;
84
- right : 0 ;
85
- height : 100 % ;
62
+ height : $md-slider-track-thickness ;
63
+ width : 100 % ;
64
+ overflow : hidden ;
86
65
}
87
66
88
- .md-slider-track-fill {
89
- transition-duration : $swift-ease-out-duration ;
90
- transition-timing-function : $swift-ease-out-timing-function ;
91
- transition-property : width , height ;
67
+ .md-slider-ticks {
68
+ background : repeating-linear-gradient (to right , $md-slider-tick-color ,
69
+ $md-slider-tick-color $md-slider-tick-size , transparent 0 , transparent ) repeat-x ;
70
+ height : $md-slider-track-thickness ;
71
+ width : 100% ;
72
+ opacity : 0 ;
73
+ transition : opacity $swift-ease-out-duration $swift-ease-out-timing-function ;
92
74
}
93
75
94
- .md-slider-tick-container , .md-slider-last-tick-container {
95
- position : absolute ;
96
- left : 0 ;
97
- right : 0 ;
98
- height : 100% ;
76
+ .md-slider-has-ticks.md-slider-active .md-slider-ticks ,
77
+ .md-slider-has-ticks :hover .md-slider-ticks {
78
+ opacity : 1 ;
99
79
}
100
80
101
81
.md-slider-thumb-container {
102
- position : absolute ;
103
- left : 0 ;
104
- top : 50% ;
105
- transform : translate3d (-50% , -50% , 0 );
106
- transition-duration : $swift-ease-out-duration ;
107
- transition-timing-function : $swift-ease-out-timing-function ;
108
- transition-property : left , bottom ;
109
- }
110
-
111
- .md-slider-thumb-position {
112
- transition : transform $swift-ease-out-duration $swift-ease-out-timing-function ;
82
+ flex : 0 0 auto ;
83
+ position : relative ;
84
+ width : 0 ;
85
+ height : 0 ;
113
86
}
114
87
115
88
.md-slider-thumb {
116
- z-index : 1 ;
117
-
118
- @include slider-thumb-position ($md-slider-thumb-size , $md-slider-thumb-size );
89
+ position : absolute ;
90
+ left : - $md-slider-thumb-size / 2 ;
91
+ top : - $md-slider-thumb-size / 2 ;
92
+ width : $md-slider-thumb-size ;
93
+ height : $md-slider-thumb-size ;
94
+ border-radius : 50% ;
95
+ transform-origin : 50% 50% ;
119
96
transform : scale ($md-slider-thumb-default-scale );
120
97
transition : transform $swift-ease-out-duration $swift-ease-out-timing-function ;
121
98
}
122
99
123
- .md-slider-thumb ::after {
124
- content : ' ' ;
125
- position : absolute ;
126
- width : $md-slider-thumb-size ;
127
- height : $md-slider-thumb-size ;
128
- border-radius : max ($md-slider-thumb-size , $md-slider-thumb-size );
129
- // Separate border properties because, if you combine them into "border", it defaults to 'black'.
130
- border-width : 3px ;
131
- border-style : solid ;
132
- transition : inherit ;
100
+ .md-slider-active .md-slider-thumb {
101
+ transform : scale ($md-slider-thumb-focus-scale );
102
+ }
103
+
104
+ .md-slider-active.md-slider-thumb-label-showing .md-slider-thumb {
105
+ transform : scale (0 );
133
106
}
134
107
135
108
.md-slider-thumb-label {
136
109
display : flex ;
137
110
align-items : center ;
138
111
justify-content : center ;
139
-
140
112
position : absolute ;
141
- left : - ( $md-slider-thumb-label-size / 2 ) ;
142
- top : $md-slider-thumb-label-top ;
113
+ left : - $md-slider-thumb-label-size / 2 ;
114
+ top : - ( $md-slider-thumb-label-size + $md-slider-thumb-arrow-gap ) ;
143
115
width : $md-slider-thumb-label-size ;
144
116
height : $md-slider-thumb-label-size ;
145
117
border-radius : 50% ;
146
-
147
- transform : scale ( 0.4 ) translate3d ( 0 , ( - $md-slider-thumb-label-top + 10 ) / 0.4 , 0 ) rotate (45deg );
118
+ transform : translateY ( $md-slider-thumb-label-size / 2 + $md-slider-thumb-arrow-gap )
119
+ scale ( 0.4 ) rotate (45deg );
148
120
transition : 300ms $swift-ease-in-out-timing-function ;
149
121
transition-property : transform , border-radius ;
150
122
}
151
123
124
+ .md-slider-active .md-slider-thumb-label {
125
+ border-radius : 50% 50% 0 ;
126
+ transform : rotate (45deg );
127
+ }
128
+
129
+ md-slider :not (.md-slider-thumb-label-showing ) .md-slider-thumb-label {
130
+ display : none ;
131
+ }
132
+
152
133
.md-slider-thumb-label-text {
153
134
z-index : 1 ;
154
135
font-size : 12px ;
@@ -158,29 +139,6 @@ md-slider *::after {
158
139
transition : opacity 300ms $swift-ease-in-out-timing-function ;
159
140
}
160
141
161
- .md-slider-container :not (.md-slider-thumb-label-showing ) .md-slider-thumb-label {
162
- display : none ;
163
- }
164
-
165
- .md-slider-active.md-slider-thumb-label-showing .md-slider-thumb {
166
- transform : scale (0 );
167
- }
168
-
169
- .md-slider-sliding .md-slider-thumb-position ,
170
- .md-slider-sliding .md-slider-track-fill {
171
- transition : none ;
172
- cursor : default ;
173
- }
174
-
175
- .md-slider-active .md-slider-thumb {
176
- transform : scale ($md-slider-thumb-focus-scale );
177
- }
178
-
179
- .md-slider-active .md-slider-thumb-label {
180
- border-radius : 50% 50% 0 ;
181
- transform : rotate (45deg );
182
- }
183
-
184
142
.md-slider-active .md-slider-thumb-label-text {
185
143
opacity : 1 ;
186
144
}
0 commit comments