@@ -82,7 +82,7 @@ export type SliderProps = Omit<ThumbProps, 'ref'> & {
82
82
*/
83
83
onSeekEnd ?: ( ) => void ;
84
84
/**
85
- * Callback that notifies when the reset function was invoked
85
+ * Callback that notifies when the reset function was invoked
86
86
*/
87
87
onReset ?: ( ) => void ;
88
88
/**
@@ -121,7 +121,7 @@ export type SliderProps = Omit<ThumbProps, 'ref'> & {
121
121
* The slider's test identifier
122
122
*/
123
123
testID ?: string ;
124
- /**
124
+ /**
125
125
* Whether to use the new Slider implementation using Reanimated
126
126
*/
127
127
migrate ?: boolean ;
@@ -169,10 +169,10 @@ export default class Slider extends PureComponent<SliderProps, State> {
169
169
private minThumb = React . createRef < RNView > ( ) ;
170
170
private activeThumbRef : React . RefObject < RNView > ;
171
171
private panResponder ;
172
-
172
+
173
173
private minTrack = React . createRef < RNView > ( ) ;
174
174
private _minTrackStyles : MinTrackStyle = { } ;
175
-
175
+
176
176
private _x = 0 ;
177
177
private _x_min = 0 ;
178
178
private lastDx = 0 ;
@@ -270,18 +270,18 @@ export default class Slider extends PureComponent<SliderProps, State> {
270
270
271
271
componentDidUpdate ( prevProps : SliderProps , prevState : State ) {
272
272
const { useRange, value, initialMinimumValue} = this . props ;
273
-
273
+
274
274
if ( ! useRange && prevProps . value !== value ) {
275
275
this . initialValue = this . getRoundedValue ( value ) ;
276
-
276
+
277
277
// set position for new value
278
278
this . _x = this . getXForValue ( this . initialValue ) ;
279
279
this . moveTo ( this . _x ) ;
280
280
}
281
281
282
282
if ( prevState . measureCompleted !== this . state . measureCompleted ) {
283
283
this . initialThumbSize = this . state . thumbSize ; // for thumb enlargement
284
-
284
+
285
285
// set initial position
286
286
this . _x = this . getXForValue ( this . initialValue ) ;
287
287
this . _x_min = this . getXForValue ( this . minInitialValue ) ;
@@ -395,16 +395,16 @@ export default class Slider extends PureComponent<SliderProps, State> {
395
395
const nonOverlappingTrackWidth = trackSize . width - this . initialThumbSize . width ;
396
396
const _x = this . shouldForceLTR ? trackSize . width - x : x ; // adjust for RTL
397
397
const left = trackSize . width === 0 ? _x : ( _x * nonOverlappingTrackWidth ) / trackSize . width ; // do not render above prefix\suffix icon\text
398
-
398
+
399
399
if ( useRange ) {
400
400
const minThumbPosition = this . _minThumbStyles ?. left as number ;
401
- if ( useGap && left > minThumbPosition + thumbSize . width + MIN_RANGE_GAP
401
+ if ( useGap && left > minThumbPosition + thumbSize . width + MIN_RANGE_GAP
402
402
|| ! useGap && left >= minThumbPosition ) {
403
403
this . _thumbStyles . left = left ;
404
-
404
+
405
405
const width = left - minThumbPosition ;
406
406
this . _minTrackStyles . width = width ;
407
-
407
+
408
408
if ( this . didMount ) {
409
409
this . updateValue ( x ) ;
410
410
}
@@ -413,9 +413,9 @@ export default class Slider extends PureComponent<SliderProps, State> {
413
413
this . _thumbStyles . left = left ;
414
414
this . _minTrackStyles . width = Math . min ( trackSize . width , x ) ;
415
415
}
416
-
417
- this . thumb . current . setNativeProps ( this . _thumbStyles ) ;
418
- this . minTrack . current ?. setNativeProps ( this . _minTrackStyles ) ;
416
+
417
+ this . thumb . current ? .setNativeProps ?. ( this . _thumbStyles ) ;
418
+ this . minTrack . current ?. setNativeProps ?. ( this . _minTrackStyles ) ;
419
419
}
420
420
} else {
421
421
this . moveMinTo ( x ) ;
@@ -430,18 +430,18 @@ export default class Slider extends PureComponent<SliderProps, State> {
430
430
const nonOverlappingTrackWidth = trackSize . width - this . initialThumbSize . width ;
431
431
const _x = this . shouldForceLTR ? nonOverlappingTrackWidth - x : x ; // adjust for RTL
432
432
const left = trackSize . width === 0 ? _x : ( _x * nonOverlappingTrackWidth ) / trackSize . width ; // do not render above prefix\suffix icon\text
433
-
433
+
434
434
const maxThumbPosition = this . _thumbStyles ?. left as number ;
435
- if ( useGap && left < maxThumbPosition - thumbSize . width - MIN_RANGE_GAP
435
+ if ( useGap && left < maxThumbPosition - thumbSize . width - MIN_RANGE_GAP
436
436
|| ! useGap && left <= maxThumbPosition ) {
437
437
this . _minThumbStyles . left = left ;
438
-
438
+
439
439
this . _minTrackStyles . width = maxThumbPosition - x ;
440
440
this . _minTrackStyles . left = x ;
441
-
442
- this . minThumb . current ?. setNativeProps ( this . _minThumbStyles ) ;
443
- this . minTrack . current ?. setNativeProps ( this . _minTrackStyles ) ;
444
-
441
+
442
+ this . minThumb . current ?. setNativeProps ?. ( this . _minThumbStyles ) ;
443
+ this . minTrack . current ?. setNativeProps ?. ( this . _minTrackStyles ) ;
444
+
445
445
if ( this . didMount ) {
446
446
this . updateValue ( x ) ;
447
447
}
@@ -464,9 +464,9 @@ export default class Slider extends PureComponent<SliderProps, State> {
464
464
this . setActiveThumb ( this . thumb ) ;
465
465
}
466
466
}
467
-
467
+
468
468
this . set_x ( newX ) ;
469
-
469
+
470
470
if ( ! useRange ) {
471
471
this . updateValue ( this . get_x ( ) ) ;
472
472
}
@@ -550,7 +550,7 @@ export default class Slider extends PureComponent<SliderProps, State> {
550
550
}
551
551
552
552
let values = { min : this . lastMinValue , max : this . lastValue } ;
553
-
553
+
554
554
if ( Constants . isRTL && this . props . disableRTL ) { // forceRTL for range slider
555
555
const { maximumValue} = this . props ;
556
556
values = { min : maximumValue - this . lastValue , max : maximumValue - this . lastMinValue } ;
@@ -749,7 +749,7 @@ export default class Slider extends PureComponent<SliderProps, State> {
749
749
if ( migrate ) {
750
750
return < IncubatorSlider { ...this . props } /> ;
751
751
}
752
-
752
+
753
753
return (
754
754
< View
755
755
style = { [ styles . container , containerStyle ] }
0 commit comments