Skip to content

Commit 54eb224

Browse files
* minRange, onTouchStart and onTouchEnd added to prop types
* default value of onValueChanged removed * version changed to 2.1.1
1 parent e3e40af commit 54eb224

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {useThumbFollower, useLowHigh, useWidthLayout, useLabelContainerProps, us
77
import {clamp, getValueForPosition, isLowCloser} from './helpers';
88

99
const trueFunc = () => true;
10-
const noop = () => {};
1110

1211
const Slider = (
1312
{
@@ -62,7 +61,7 @@ const Slider = (
6261
const lowPosition = (low - min) / (max - min) * (containerWidth - thumbWidth);
6362
lowThumbX.setValue(lowPosition);
6463
updateSelectedRail();
65-
onValueChanged(low, high, false);
64+
onValueChanged?.(low, high, false);
6665
}, [disableRange, inPropsRef, max, min, onValueChanged, thumbWidth, updateSelectedRail]);
6766

6867
useEffect(() => {
@@ -152,7 +151,7 @@ const Slider = (
152151
gestureStateRef.current.lastValue = value;
153152
gestureStateRef.current.lastPosition = absolutePosition + thumbWidth / 2;
154153
(isLow ? lowThumbX : highThumbX).setValue(absolutePosition);
155-
onValueChanged(isLow ? value : low, isLow ? high : value, true);
154+
onValueChanged?.(isLow ? value : low, isLow ? high : value, true);
156155
(isLow ? setLow : setHigh)(value);
157156
labelUpdate && labelUpdate(gestureStateRef.current.lastPosition, value);
158157
notchUpdate && notchUpdate(gestureStateRef.current.lastPosition, value);
@@ -206,6 +205,7 @@ Slider.propTypes = {
206205
...ViewPropTypes,
207206
min: PropTypes.number.isRequired,
208207
max: PropTypes.number.isRequired,
208+
minRange: PropTypes.number,
209209
step: PropTypes.number.isRequired,
210210
renderThumb: PropTypes.func.isRequired,
211211
low: PropTypes.number,
@@ -219,6 +219,8 @@ Slider.propTypes = {
219219
renderRail: PropTypes.func.isRequired,
220220
renderRailSelected: PropTypes.func.isRequired,
221221
onValueChanged: PropTypes.func,
222+
onTouchStart: PropTypes.func,
223+
onTouchEnd: PropTypes.func,
222224
};
223225

224226
Slider.defaultProps = {
@@ -227,7 +229,6 @@ Slider.defaultProps = {
227229
disableRange: false,
228230
disabled: false,
229231
floatingLabel: false,
230-
onValueChanged: noop,
231232
};
232233

233234
export default memo(Slider);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-range-slider",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"author": "Tigran Sahakyan <mail.of.tigran@gmail.com>",
55
"description": "A highly optimized pure JS implementation of Range Slider for React Native",
66
"homepage": "https://github.com/githuboftigran/rn-range-slider",

0 commit comments

Comments
 (0)