@@ -30,7 +30,7 @@ const INACTIVE_COLOR = Colors.$backgroundNeutralMedium;
30
30
const MIN_RANGE_GAP = 4 ;
31
31
32
32
export type SliderOnValueChange = ( value : number ) => void ;
33
- export type SliderOnRangeChange = ( values : { min : number , max : number } ) => void ;
33
+ export type SliderOnRangeChange = ( values : { min : number ; max : number } ) => void ;
34
34
35
35
export type SliderProps = Omit < ThumbProps , 'ref' > & {
36
36
/**
@@ -142,7 +142,7 @@ type Measurements = {
142
142
143
143
type ThumbStyle = { style ?: StyleProp < ViewStyle > ; left ?: StyleProp < number > } ;
144
144
145
- type MinTrackStyle = { style ?: StyleProp < ViewStyle > ; width ?: StyleProp < number > , left ?: StyleProp < number > } ;
145
+ type MinTrackStyle = { style ?: StyleProp < ViewStyle > ; width ?: StyleProp < number > ; left ?: StyleProp < number > } ;
146
146
147
147
type MeasuredVariableName = 'containerSize' | 'trackSize' | 'thumbSize' ;
148
148
@@ -220,7 +220,8 @@ export default class Slider extends PureComponent<SliderProps, State> {
220
220
} ) ;
221
221
}
222
222
223
- reset ( ) { // NOTE: used with ref
223
+ reset ( ) {
224
+ // NOTE: used with ref
224
225
this . lastValue = this . initialValue ;
225
226
this . lastMinValue = this . minInitialValue ;
226
227
this . lastDx = 0 ;
@@ -399,8 +400,10 @@ export default class Slider extends PureComponent<SliderProps, State> {
399
400
400
401
if ( useRange ) {
401
402
const minThumbPosition = this . _minThumbStyles ?. left as number ;
402
- if ( useGap && left > minThumbPosition + thumbSize . width + MIN_RANGE_GAP
403
- || ! useGap && left >= minThumbPosition ) {
403
+ if (
404
+ ( useGap && left > minThumbPosition + thumbSize . width + MIN_RANGE_GAP ) ||
405
+ ( ! useGap && left >= minThumbPosition )
406
+ ) {
404
407
this . _thumbStyles . left = left ;
405
408
406
409
const width = left - minThumbPosition ;
@@ -433,8 +436,10 @@ export default class Slider extends PureComponent<SliderProps, State> {
433
436
const left = trackSize . width === 0 ? _x : ( _x * nonOverlappingTrackWidth ) / trackSize . width ; // do not render above prefix\suffix icon\text
434
437
435
438
const maxThumbPosition = this . _thumbStyles ?. left as number ;
436
- if ( useGap && left < maxThumbPosition - thumbSize . width - MIN_RANGE_GAP
437
- || ! useGap && left <= maxThumbPosition ) {
439
+ if (
440
+ ( useGap && left < maxThumbPosition - thumbSize . width - MIN_RANGE_GAP ) ||
441
+ ( ! useGap && left <= maxThumbPosition )
442
+ ) {
438
443
this . _minThumbStyles . left = left ;
439
444
440
445
this . _minTrackStyles . width = maxThumbPosition - x ;
@@ -483,7 +488,8 @@ export default class Slider extends PureComponent<SliderProps, State> {
483
488
484
489
get disableRTL ( ) {
485
490
const { disableRTL, useRange} = this . props ;
486
- if ( useRange ) { // block forceRTL on range slider
491
+ if ( useRange ) {
492
+ // block forceRTL on range slider
487
493
return false ;
488
494
}
489
495
return disableRTL ;
@@ -552,7 +558,8 @@ export default class Slider extends PureComponent<SliderProps, State> {
552
558
553
559
let values = { min : this . lastMinValue , max : this . lastValue } ;
554
560
555
- if ( Constants . isRTL && this . props . disableRTL ) { // forceRTL for range slider
561
+ if ( Constants . isRTL && this . props . disableRTL ) {
562
+ // forceRTL for range slider
556
563
const { maximumValue} = this . props ;
557
564
values = { min : maximumValue - this . lastValue , max : maximumValue - this . lastMinValue } ;
558
565
}
@@ -693,40 +700,35 @@ export default class Slider extends PureComponent<SliderProps, State> {
693
700
maximumTrackTintColor = DEFAULT_COLOR
694
701
} = this . props ;
695
702
696
- return (
697
- _ . isFunction ( renderTrack ) ? (
703
+ return _ . isFunction ( renderTrack ) ? (
704
+ < View style = { [ styles . track , { backgroundColor : maximumTrackTintColor } , trackStyle ] } onLayout = { this . onTrackLayout } >
705
+ { renderTrack ( ) }
706
+ </ View >
707
+ ) : (
708
+ < View >
698
709
< View
699
- style = { [ styles . track , { backgroundColor : maximumTrackTintColor } , trackStyle ] }
710
+ style = { [
711
+ styles . track ,
712
+ trackStyle ,
713
+ {
714
+ backgroundColor : disabled ? INACTIVE_COLOR : maximumTrackTintColor
715
+ }
716
+ ] }
700
717
onLayout = { this . onTrackLayout }
701
- >
702
- { renderTrack ( ) }
703
- </ View >
704
- ) : (
705
- < View >
706
- < View
707
- style = { [
708
- styles . track ,
709
- trackStyle ,
710
- {
711
- backgroundColor : disabled ? INACTIVE_COLOR : maximumTrackTintColor
712
- }
713
- ] }
714
- onLayout = { this . onTrackLayout }
715
- />
716
- < View
717
- ref = { this . minTrack }
718
- style = { [
719
- styles . track ,
720
- trackStyle ,
721
- styles . minimumTrack ,
722
- this . shouldForceLTR && styles . trackDisableRTL ,
723
- {
724
- backgroundColor : disabled ? DEFAULT_COLOR : minimumTrackTintColor
725
- }
726
- ] }
727
- />
728
- </ View >
729
- )
718
+ />
719
+ < View
720
+ ref = { this . minTrack }
721
+ style = { [
722
+ styles . track ,
723
+ trackStyle ,
724
+ styles . minimumTrack ,
725
+ this . shouldForceLTR && styles . trackDisableRTL ,
726
+ {
727
+ backgroundColor : disabled ? DEFAULT_COLOR : minimumTrackTintColor
728
+ }
729
+ ] }
730
+ />
731
+ </ View >
730
732
) ;
731
733
}
732
734
@@ -736,11 +738,7 @@ export default class Slider extends PureComponent<SliderProps, State> {
736
738
if ( useGap ) {
737
739
return this . renderMinThumb ( ) ;
738
740
}
739
- return (
740
- < View style = { { zIndex : this . isDefaultThumbActive ( ) ? 0 : 1 , top : '-50%' } } >
741
- { this . renderMinThumb ( ) }
742
- </ View >
743
- ) ;
741
+ return < View style = { { zIndex : this . isDefaultThumbActive ( ) ? 0 : 1 , top : '-50%' } } > { this . renderMinThumb ( ) } </ View > ;
744
742
}
745
743
}
746
744
0 commit comments