@@ -152,6 +152,7 @@ export class VcfSlider extends LitElement {
152
152
case 'value' : {
153
153
this . setLabelValues ( ) ;
154
154
this . knobIndexes . forEach ( i => {
155
+ this . setAriaValues ( i ) ;
155
156
this . setLabelPosition ( i ) ;
156
157
this . setKnobPostion ( i ) ;
157
158
this . setLineColors ( ) ;
@@ -166,10 +167,20 @@ export class VcfSlider extends LitElement {
166
167
const { knobIndexes, values } = this ;
167
168
knobIndexes . forEach ( i => {
168
169
const labelElement = this . labelElement ( i ) as HTMLElement ;
169
- if ( this . labelElement ( i ) ) labelElement . innerText = `${ values [ i ] } ` ;
170
+ if ( labelElement ) labelElement . innerText = `${ values [ i ] } ` ;
170
171
} ) ;
171
172
}
172
173
174
+ private setAriaValues ( i = 0 ) {
175
+ const { knobIndexes, values, knobs, min, max, labels } = this ;
176
+ const knob = this . knobElement ( i ) as HTMLElement ;
177
+ if ( knob ) {
178
+ knob . setAttribute ( 'aria-valuenow' , `${ values [ i ] } ` ) ;
179
+ knob . setAttribute ( 'aria-valuemin' , `${ knobs === 1 ? min : this . getPrevNeighborValue ( i ) } ` ) ;
180
+ knob . setAttribute ( 'aria-valuemax' , `${ knobs === 1 ? max : this . getNextNeighborValue ( i ) } ` ) ;
181
+ }
182
+ }
183
+
173
184
private get initialValue ( ) {
174
185
const { knobs, min, max, step } = this ;
175
186
const valueStep = ( max - min ) / ( knobs - 1 ) ;
@@ -372,21 +383,21 @@ export class VcfSlider extends LitElement {
372
383
}
373
384
374
385
private getPrevNeighborValue ( knobIndex : number ) {
375
- const { values, step } = this ;
386
+ const { values, step, min } = this ;
376
387
let neighboringValue ;
377
388
neighboringValue = values [ knobIndex - 1 ] ;
378
389
const neighborPrecisionOffset = neighboringValue % step ;
379
390
if ( neighborPrecisionOffset ) neighboringValue += step - neighborPrecisionOffset ;
380
- return neighboringValue ;
391
+ return neighboringValue ? neighboringValue : min ;
381
392
}
382
393
383
394
private getNextNeighborValue ( knobIndex : number ) {
384
- const { values, step } = this ;
395
+ const { values, step, max } = this ;
385
396
let neighboringValue ;
386
397
neighboringValue = values [ knobIndex + 1 ] ;
387
398
const neighborPrecisionOffset = neighboringValue % step ;
388
399
if ( neighborPrecisionOffset ) neighboringValue -= neighborPrecisionOffset ;
389
- return neighboringValue ;
400
+ return neighboringValue ? neighboringValue : max ;
390
401
}
391
402
392
403
private decreaseKnobValue ( { knobIndex, single, first = this . min , other } : KnobValueOptions ) {
0 commit comments