Skip to content

Commit 9584c1a

Browse files
committed
feat: enhance RangeSlider component with initial value props and updated README
1 parent c65d1a7 commit 9584c1a

File tree

5 files changed

+249
-159
lines changed

5 files changed

+249
-159
lines changed

README.md

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,47 @@ A high-performance React Native range slider component built with [react-native-
2020

2121
This slider leverages two powerful libraries for optimal performance, while maintaining a pure JavaScript implementation:
2222

23-
- **react-native-reanimated**: Runs animations directly on the UI thread, eliminating JS-bridge overhead and ensuring smooth 60 FPS animations even during complex interactions
23+
- **react-native-reanimated**: Runs animations directly on the UI thread, eliminating JS-bridge overhead and ensuring smooth 60 FPS animations
2424
- **react-native-gesture-handler**: Provides native-driven gesture handling, resulting in more responsive touch interactions compared to React Native's PanResponder
2525

2626
Both dependencies are widely adopted in the React Native ecosystem and don't require any additional native code configuration.
2727

28-
## Installation
28+
## Preview
29+
30+
<table>
31+
<tr>
32+
<td><img width="200" src="assets/demo01.gif" alt="Range Slider Demo"></td>
33+
</tr>
34+
</table>
35+
36+
## Prerequisites
2937

38+
This library requires [react-native-reanimated](https://www.npmjs.com/package/react-native-reanimated) and [react-native-gesture-handler](https://www.npmjs.com/package/react-native-gesture-handler).
39+
40+
### Expo Users
41+
Both libraries are supported out of the box:
3042
```bash
31-
npm install react-native-range-slider-fast
32-
# or
33-
yarn add react-native-range-slider-fast
43+
npx expo install react-native-reanimated react-native-gesture-handler
3444
```
3545

36-
### Dependencies
37-
38-
This library requires:
46+
### React Native CLI Users
47+
1. Install the packages:
3948
```bash
4049
yarn add react-native-reanimated react-native-gesture-handler
4150
```
4251

52+
2. Follow the additional setup instructions in:
53+
- [Reanimated Installation Guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started)
54+
- [Gesture Handler Installation Guide](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation)
55+
56+
## Installation
57+
58+
```bash
59+
npm install react-native-range-slider-fast
60+
# or
61+
yarn add react-native-range-slider-fast
62+
```
63+
4364
## Usage
4465

4566
```javascript
@@ -52,26 +73,31 @@ const YourComponent = () => {
5273

5374
return (
5475
<RangeSlider
55-
values={[20, 80]}
76+
initialMinValue={20}
77+
initialMaxValue={80}
5678
min={0}
5779
max={100}
5880
step={1}
5981
// Style customization
82+
width={300}
83+
thumbSize={32}
84+
trackHeight={2.5}
6085
selectedTrackStyle={{ backgroundColor: '#2196F3' }}
6186
unselectedTrackStyle={{ backgroundColor: '#CECECE' }}
62-
markerStyle={{ backgroundColor: 'white' }}
63-
pressedMarkerStyle={{ transform: [{ scale: 1.2 }] }}
87+
thumbStyle={{ backgroundColor: 'white' }}
88+
pressedThumbStyle={{ transform: [{ scale: 1.2 }] }}
6489
// Behavior
6590
enabled={true}
6691
allowOverlap={false}
67-
showMarkerLines={true}
92+
showThumbLines={true}
93+
minimumDistance={16}
6894
// Callbacks
6995
onValuesChange={handleValuesChange}
7096
onValuesChangeStart={(values) => console.log('Started:', values)}
7197
onValuesChangeFinish={(values) => console.log('Finished:', values)}
7298
// Accessibility
73-
leftMarkerAccessibilityLabel="Minimum value"
74-
rightMarkerAccessibilityLabel="Maximum value"
99+
leftThumbAccessibilityLabel="Minimum value"
100+
rightThumbAccessibilityLabel="Maximum value"
75101
/>
76102
);
77103
};
@@ -81,25 +107,33 @@ const YourComponent = () => {
81107

82108
| Prop | Type | Required | Default | Description |
83109
|------|------|----------|---------|-------------|
84-
| values | [number, number] | Yes | - | Current values array [min, max] |
110+
| **Core Props** |
85111
| min | number | Yes | - | Minimum allowed value |
86112
| max | number | Yes | - | Maximum allowed value |
113+
| initialMinValue | number | No | min | Initial minimum value |
114+
| initialMaxValue | number | No | max | Initial maximum value |
87115
| step | number | No | 1 | Step size for value changes |
88-
| sliderWidth | number | No | 270 | Width of the slider track |
116+
| **Customization Props** |
117+
| width | number | No | 270 | Width of the slider track |
89118
| thumbSize | number | No | 32 | Size of thumb handles |
90119
| trackHeight | number | No | 2.5 | Height of slider track |
91120
| minimumDistance | number | No | 16 | Minimum distance between thumbs |
92-
| enabled | boolean | No | true | Enable/disable slider |
93-
| allowOverlap | boolean | No | false | Allow thumbs to overlap |
94121
| showThumbLines | boolean | No | true | Show lines inside thumb handles |
122+
| **Style Props** |
95123
| selectedTrackStyle | object | No | - | Style object for selected track portion |
96124
| unselectedTrackStyle | object | No | - | Style object for unselected track portion |
97125
| thumbStyle | object | No | - | Style object for both thumbs |
98126
| pressedThumbStyle | object | No | - | Style applied when thumb is pressed |
99127
| containerStyle | object | No | - | Style for the container view |
128+
| selectedTrackColor | string | No | '#2196F3' | Color of the selected track portion |
129+
| **Behavior Props** |
130+
| enabled | boolean | No | true | Enable/disable slider |
131+
| allowOverlap | boolean | No | false | Allow thumbs to overlap |
132+
| **Callback Props** |
100133
| onValuesChange | function | No | () => {} | Called while dragging |
101134
| onValuesChangeStart | function | No | () => {} | Called when drag starts |
102135
| onValuesChangeFinish | function | No | () => {} | Called when drag ends |
136+
| **Accessibility Props** |
103137
| leftThumbAccessibilityLabel | string | No | "Left handle" | Accessibility label for left thumb |
104138
| rightThumbAccessibilityLabel | string | No | "Right handle" | Accessibility label for right thumb |
105139

@@ -119,8 +153,8 @@ The component supports several style customization props:
119153
height: 4,
120154
}}
121155

122-
// Marker styles
123-
markerStyle={{
156+
// Thumb styles
157+
thumbStyle={{
124158
backgroundColor: 'white',
125159
borderColor: '#CECECE',
126160
borderWidth: 0.5,
@@ -130,8 +164,8 @@ The component supports several style customization props:
130164
shadowRadius: 3.84,
131165
}}
132166

133-
// Pressed marker style
134-
pressedMarkerStyle={{
167+
// Pressed thumb style
168+
pressedThumbStyle={{
135169
transform: [{ scale: 1.2 }],
136170
}}
137171

@@ -140,8 +174,8 @@ The component supports several style customization props:
140174
height: 50,
141175
}}
142176

143-
// Show/hide marker lines
144-
showMarkerLines={true}
177+
// Show/hide thumb lines
178+
showThumbLines={true}
145179
/>
146180
```
147181

assets/demo01.gif

1.02 MB
Loading

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@
4545
"ios",
4646
"android",
4747
"range-slider",
48+
"multi-slider",
49+
"dual-slider",
50+
"dual",
51+
"multi",
4852
"slider",
49-
"range",
50-
"reanimated",
51-
"gesture-handler",
52-
"performance",
53-
"touch",
54-
"interactive"
53+
"range"
5554
],
5655
"repository": {
5756
"type": "git",

0 commit comments

Comments
 (0)