@@ -61,6 +61,8 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
61
61
*/
62
62
static readonly formAssociated = true ;
63
63
64
+ #stepDecimalPlaces = 0 ;
65
+
64
66
/**
65
67
* Hides the numbers representing the value of each steps. Dots will still be visible
66
68
* @type {boolean }
@@ -70,6 +72,15 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
70
72
@property ( { type : Boolean , attribute : 'hide-step-values' } )
71
73
hideStepValues = false ;
72
74
75
+ /**
76
+ * Hides the value label on the thumb.
77
+ * @type {boolean }
78
+ * @attr 'hide-value-label'
79
+ * @default false
80
+ */
81
+ @property ( { type : Boolean , attribute : 'hide-value-label' } )
82
+ hideValueLabel = false ;
83
+
73
84
/**
74
85
* This is a minimum value of the input.
75
86
* @type {number }
@@ -95,7 +106,16 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
95
106
* @default 1
96
107
*/
97
108
@property ( { type : Number } )
98
- step = 1 ;
109
+ public get step ( ) {
110
+ return this . #step;
111
+ }
112
+
113
+ public set step ( value ) {
114
+ this . #step = value ;
115
+ this . #stepDecimalPlaces = ( value . toString ( ) . split ( '.' ) [ 1 ] || [ ] ) . length ;
116
+ }
117
+
118
+ #step = 1 ;
99
119
100
120
/**
101
121
* This is a value property of the uui-slider.
@@ -117,11 +137,13 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
117
137
118
138
let correctedValue = newVal ? parseFloat ( newVal as string ) : 0 ;
119
139
correctedValue = Math . min ( Math . max ( correctedValue , this . min ) , this . max ) ;
140
+
120
141
if ( this . step > 0 ) {
121
142
correctedValue = Math . round ( correctedValue / this . step ) * this . step ;
122
143
}
123
144
124
- super . value = correctedValue . toString ( ) ;
145
+ super . value = correctedValue . toFixed ( this . #stepDecimalPlaces) . toString ( ) ;
146
+
125
147
this . _calculateSliderPosition ( ) ;
126
148
this . requestUpdate ( 'value' , oldVal ) ;
127
149
}
@@ -285,7 +307,9 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
285
307
286
308
<div id= "track-inner" aria-hidden = "true">
287
309
<div id= "thumb" style = ${ styleMap ( { left : this . _sliderPosition } ) } >
288
- <div id= "thumb-label" > ${ this . value } </ div>
310
+ ${ this . hideValueLabel
311
+ ? null
312
+ : html `<div id= "thumb-label" > ${ this . value } </ div> ` }
289
313
</ div>
290
314
</ div>
291
315
</ div>
@@ -350,6 +374,9 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
350
374
351
375
# thumb {
352
376
position : absolute;
377
+ display : flex;
378
+ align-items : center;
379
+ justify-content : center;
353
380
top : 2px ;
354
381
bottom : 0 ;
355
382
left : 0 ;
@@ -362,8 +389,6 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
362
389
363
390
background-color : var (--uui-color-surface );
364
391
border : 2px solid var (--uui-color-selected );
365
-
366
- transition : 120ms left ease;
367
392
}
368
393
: host ([disabled ]) # thumb {
369
394
background-color : var (--uui-color-disabled );
@@ -372,9 +397,6 @@ export class UUISliderElement extends UUIFormControlMixin(LitElement, '') {
372
397
373
398
# thumb : after {
374
399
content : '' ;
375
- position : absolute;
376
- top : 2px ;
377
- left : 2px ;
378
400
height : 9px ;
379
401
width : 9px ;
380
402
border-radius : 50% ;
0 commit comments