File tree Expand file tree Collapse file tree 2 files changed +39
-8
lines changed
packages/calcite-components/src/components/slider Expand file tree Collapse file tree 2 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,37 @@ export const maxTickRendering_TestOnly = (): string => html`
415
415
< calcite-slider min ="-1000 " max ="1000 " ticks ="10 "> </ calcite-slider >
416
416
` ;
417
417
418
+ export const rendersWhenTrackRelatedPropChanges_TestOnly = ( ) : string =>
419
+ html `
420
+ < calcite-slider
421
+ id ="example-slider "
422
+ label-ticks
423
+ max ="32 "
424
+ value ="24 "
425
+ min ="16 "
426
+ snap
427
+ step ="8 "
428
+ ticks ="8 "
429
+ > </ calcite-slider >
430
+ < script >
431
+ ( async ( ) => {
432
+ await customElements . whenDefined ( "calcite-slider" ) ;
433
+ const slider = await document . querySelector ( "calcite-slider" ) . componentOnReady ( ) ;
434
+ await new Promise ( ( resolve ) => requestAnimationFrame ( resolve ) ) ;
435
+
436
+ slider . max = 64 ;
437
+ slider . min = 48 ;
438
+ slider . step = 16 ;
439
+ slider . ticks = 16 ;
440
+ slider . value = 64 ;
441
+ } ) ( ) ;
442
+ </ script >
443
+ ` ;
444
+
445
+ rendersWhenTrackRelatedPropChanges_TestOnly . parameters = {
446
+ chromatic : { delay : 500 } ,
447
+ } ;
448
+
418
449
export const spaceGroupSeparatorNoBreak_TestOnly = ( ) : string => html `
419
450
< calcite-slider
420
451
lang ="ru "
Original file line number Diff line number Diff line change @@ -182,6 +182,11 @@ export class Slider
182
182
/** Displays tick marks on the number line at a specified interval. */
183
183
@Prop ( { reflect : true } ) ticks : number ;
184
184
185
+ @Watch ( "ticks" )
186
+ ticksWatcher ( ) : void {
187
+ this . tickValues = this . generateTickValues ( ) ;
188
+ }
189
+
185
190
/** The component's value. */
186
191
@Prop ( { reflect : true , mutable : true } ) value : null | number | number [ ] = 0 ;
187
192
@@ -226,17 +231,12 @@ export class Slider
226
231
227
232
componentWillLoad ( ) : void {
228
233
setUpLoadableComponent ( this ) ;
229
- this . tickValues = this . generateTickValues ( ) ;
230
234
if ( ! isRange ( this . value ) ) {
231
- this . value = this . clamp ( this . value ) ;
235
+ this . value = this . snap ? this . getClosestStep ( this . value ) : this . clamp ( this . value ) ;
232
236
}
237
+ this . ticksWatcher ( ) ;
238
+ this . histogramWatcher ( this . histogram ) ;
233
239
afterConnectDefaultValueSet ( this , this . value ) ;
234
- if ( this . snap && ! isRange ( this . value ) ) {
235
- this . value = this . getClosestStep ( this . value ) ;
236
- }
237
- if ( this . histogram ) {
238
- this . hasHistogram = true ;
239
- }
240
240
}
241
241
242
242
componentDidLoad ( ) : void {
You can’t perform that action at this time.
0 commit comments