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