@@ -36,7 +36,7 @@ export const useRangeSlider = ({max, min, step, damping}: SliderConfig, range: n
3636
3737 useEffect ( ( ) => {
3838 validateSliderRange ( range ) ;
39- adjustThumbsPosition ( sliderLayout . width , true ) ;
39+ adjustThumbsPosition ( sliderLayout . width ) ;
4040 } , [ range , sliderLayout ] ) ;
4141
4242 const filledTrackAnimatedStyle = useAnimatedStyle ( ( ) => {
@@ -122,13 +122,13 @@ export const useRangeSlider = ({max, min, step, damping}: SliderConfig, range: n
122122 setSliderLayout ( layout ) ;
123123 } ;
124124
125- const adjustThumbsPosition = ( width : number , isUpdating : boolean = false ) => {
126- const initialStartTthumbTranslationX = calcTranslationXBasedOnValue ( { min, max} , normalize ( minValue , step ) , width ) ;
127- const initiaEndTthumbTranslationX = calcTranslationXBasedOnValue ( { min, max} , normalize ( maxValue , step ) , width ) ;
125+ const adjustThumbsPosition = ( width : number ) => {
126+ const initialMinTthumbTranslationX = calcTranslationXBasedOnValue ( { min, max} , normalize ( minValue , step ) , width ) ;
127+ const initiaMaxTthumbTranslationX = calcTranslationXBasedOnValue ( { min, max} , normalize ( maxValue , step ) , width ) ;
128128
129- thumbMinTranslationX . value = isUpdating ? withSpring ( initialStartTthumbTranslationX , { damping} ) : initialStartTthumbTranslationX ;
130- thumbMaxTranslationX . value = isUpdating ? withSpring ( initiaEndTthumbTranslationX , { damping} ) : initiaEndTthumbTranslationX ;
131- thumbsTranslationXContext . value = { min : initialStartTthumbTranslationX , max : initiaEndTthumbTranslationX } ;
129+ thumbMinTranslationX . value = withSpring ( initialMinTthumbTranslationX , { damping} ) ;
130+ thumbMaxTranslationX . value = withSpring ( initiaMaxTthumbTranslationX , { damping} ) ;
131+ thumbsTranslationXContext . value = { min : initialMinTthumbTranslationX , max : initiaMaxTthumbTranslationX } ;
132132 } ;
133133
134134 const slideToTrackPoint = ( pointValue : number ) => {
@@ -138,8 +138,16 @@ export const useRangeSlider = ({max, min, step, damping}: SliderConfig, range: n
138138
139139 const diffFromMinThumb = Math . abs ( pointValue - selectedRange . value [ 0 ] ) ;
140140 const diffFromMaxThumb = Math . abs ( pointValue - selectedRange . value [ 1 ] ) ;
141- const [ activeThumbSliding , activeThumbTranslationX ] =
142- diffFromMinThumb < diffFromMaxThumb ? [ thumbMinSliding , thumbMinTranslationX ] : [ thumbMaxSliding , thumbMaxTranslationX ] ;
141+
142+ let [ activeThumbSliding , activeThumbTranslationX ] = [ thumbMaxSliding , thumbMaxTranslationX ] ;
143+
144+ if ( diffFromMinThumb === diffFromMaxThumb ) {
145+ [ activeThumbSliding , activeThumbTranslationX ] =
146+ pointValue < selectedRange . value [ 0 ] ? [ thumbMinSliding , thumbMinTranslationX ] : [ thumbMaxSliding , thumbMaxTranslationX ] ;
147+ } else if ( diffFromMinThumb < diffFromMaxThumb ) {
148+ [ activeThumbSliding , activeThumbTranslationX ] = [ thumbMinSliding , thumbMinTranslationX ] ;
149+ }
150+
143151 const thumbPointValueTranslationX = calcTranslationXBasedOnValue ( { min, max} , pointValue , sliderLayout . width ) ;
144152
145153 activeThumbSliding . value = withTiming ( 1 ) ;
0 commit comments