From a9f819897b008e2e0671b2bc9957c07231ac18aa Mon Sep 17 00:00:00 2001 From: Marcoo09 Date: Thu, 7 Oct 2021 16:07:07 -0300 Subject: [PATCH 1/3] Update index.js --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c054f07..f233310 100644 --- a/index.js +++ b/index.js @@ -47,6 +47,7 @@ const Slider = ( const [selectedRailStyle, updateSelectedRail] = useSelectedRail(inPropsRef, containerWidthRef, thumbWidth, disableRange); const updateThumbs = useCallback(() => { + const { lowPrev, highPrev } = inPropsRefPrev; const { current: containerWidth } = containerWidthRef; if (!thumbWidth || !containerWidth) { return; @@ -61,8 +62,10 @@ const Slider = ( const lowPosition = (low - min) / (max - min) * (containerWidth - thumbWidth); lowThumbX.setValue(lowPosition); updateSelectedRail(); - onValueChanged?.(low, high, false); - }, [disableRange, inPropsRef, max, min, onValueChanged, thumbWidth, updateSelectedRail]); + if ((lowProp !== undefined && lowProp !== lowPrev) || (highProp !== undefined && highProp !== highPrev)) { + onValueChanged?.(low, high, false); + } + }, [disableRange, inPropsRef, max, min, onValueChanged, thumbWidth, updateSelectedRail,highProp, inPropsRefPrev.lowPrev, inPropsRefPrev.highPrev, lowProp]); useEffect(() => { const { lowPrev, highPrev } = inPropsRefPrev; From c1e64c23e600f7541cb40ab61abac5c15f2aa95b Mon Sep 17 00:00:00 2001 From: Marcoo09 Date: Thu, 7 Oct 2021 18:01:00 -0300 Subject: [PATCH 2/3] Update index.js Add value prop --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f233310..399cdae 100644 --- a/index.js +++ b/index.js @@ -28,10 +28,11 @@ const Slider = ( renderNotch, renderRail, renderRailSelected, + value, ...restProps } ) => { - const { inPropsRef, inPropsRefPrev, setLow, setHigh } = useLowHigh(lowProp, disableRange ? max : highProp, min, max, step); + const { inPropsRef, inPropsRefPrev, setLow, setHigh } = useLowHigh(value ?? lowProp, disableRange ? max : highProp, min, max, step); const lowThumbXRef = useRef(new Animated.Value(0)); const highThumbXRef = useRef(new Animated.Value(0)); const pointerX = useRef(new Animated.Value(0)).current; @@ -224,6 +225,7 @@ Slider.propTypes = { onValueChanged: PropTypes.func, onTouchStart: PropTypes.func, onTouchEnd: PropTypes.func, + value:PropTypes.number }; Slider.defaultProps = { From ae7bd93541adcf6c0f70a3252b9e358601c6661e Mon Sep 17 00:00:00 2001 From: Marcoo09 Date: Thu, 7 Oct 2021 18:25:13 -0300 Subject: [PATCH 3/3] Update package.json Update version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10ba75e..e33444c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rn-range-slider", - "version": "2.1.1", + "version": "2.1.2", "author": "Tigran Sahakyan ", "description": "A highly optimized pure JS implementation of Range Slider for React Native", "homepage": "https://github.com/githuboftigran/rn-range-slider",