You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom thumb's component with additional props (#655)
* Add new fields to MarkerProps for custom component
* Implement min, max and index into Custom Component value
* Provide new custom component with the example in example app
* Provide currentValue with defined value of Slider
* Update package name ref in example lockfile
* Fix the typing and styling
* Adjust the pods lockfile
* Remove the redundant example
* Optimize the StepsIndicator a bit by rendering only the changed
* Describe the custom components in details in README
* Simplify README by not using the screenshots
Copy file name to clipboardExpand all lines: README.md
+93-2Lines changed: 93 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,11 +107,102 @@ To use this library you need to ensure you are using the correct version of Reac
107
107
|`minimumTrackImage`| Assigns a minimum track image. Only static images are supported. The rightmost pixel of the image will be stretched to fill the track. | Image<br/>.propTypes<br/>.source | No | iOS |
108
108
|`thumbImage`| Sets an image for the thumb. Only static images are supported. Needs to be a URI of a local or network image; base64-encoded SVG is not supported. | Image<br/>.propTypes<br/>.source | No ||
109
109
|`trackImage`| Assigns a single image for the track. Only static images are supported. The center pixel of the image will be stretched to fill the track. | Image<br/>.propTypes<br/>.source | No | iOS ||
110
-
|⚠️ **Experimental:**</br> `StepMarker`| Component to be rendered for each step on the track,<br/>with the possibility to change the styling, when thumb is at that given step |`FC<MarkerProps>`, <br/> where <br/> `MarkerProps`: `{stepMarked: boolean}`| No | iOS, Android, Windows |
111
-
|⚠️ **Experimental:**</br> `renderStepNumber`| Turns on the displaying of numbers of steps.<br/>Numbers of steps are displayed under the track | bool | No | iOS, Android, Windows |
110
+
|[`StepMarker`](#stepmarker)| Component to be rendered for each step on the track,<br/>with the possibility to change the styling, when thumb is at that given step |`FC<MarkerProps>`| No | iOS, Android, Windows |
111
+
|[`renderStepNumber`](#renderstepnumber)| Turns on the displaying of numbers of steps.<br/>Numbers of steps are displayed under the track | bool | No | iOS, Android, Windows |
112
112
|`ref`| Reference object. | MutableRefObject | No | web |
It is possible to render default step numbers under your slider and to render custom step component and step marker.
118
+
<br/>This can be achieved by using:
119
+
120
+
### `renderStepNumber`
121
+
122
+
Turns on the displaying of numbers of steps.<br/>Numbers of steps are displayed under the track.
123
+
<br/>Two font sizes are available and they will be selected automatically depending on the overall number of steps.
124
+
125
+
### `StepMarker`
126
+
127
+
Your custom component rendered for every step on the Slider, both the thumb and the rest of steps along the Slider's whole length.
128
+
<br/>This `StepMarker` prop accepts your custom component and provides it with the following parameters:
129
+
130
+
<table>
131
+
<tr>
132
+
<td>
133
+
134
+
```typescript
135
+
stepMarked: boolean;
136
+
```
137
+
138
+
</td>
139
+
<td>
140
+
141
+
Indicates whether that custom step is the one that the thum is currently on.
142
+
<br/>If user drags or clicks on that step, thumb will be moved there and the `stepMarked` parameter will be set to `true`.
143
+
<br/>Use it, to differentiate between rendering your custom thumb component, or your custom step marker.
144
+
145
+
</td>
146
+
</tr>
147
+
<tr>
148
+
<td>
149
+
150
+
```typescript
151
+
currentValue: number;
152
+
```
153
+
154
+
</td>
155
+
<td>
156
+
Contains the `number` type saying at which value of the Slider the thumb currently is.
157
+
<br/>Use it, for example, to render the Slider value on every step marker, or to render different step marker's variant depending on the Thumb position.
158
+
159
+
</td>
160
+
</tr>
161
+
<tr>
162
+
<td>
163
+
164
+
```typescript
165
+
index: number;
166
+
```
167
+
168
+
</td>
169
+
<td>
170
+
171
+
Contains the index at which this exact instantiation of your custom step marker was rendered at.
172
+
<br/>Use it if you would like to render step number within the step marker, or, for example, if you want to render many variants of step marker depending on their positions along the Slider's width.
173
+
174
+
</td>
175
+
</tr>
176
+
<tr>
177
+
<td>
178
+
179
+
```typescript
180
+
min: number;
181
+
```
182
+
183
+
</td>
184
+
<td>
185
+
186
+
Minimum value of the Slider. It is equal to `minimumValue` and has the same default if not set.
187
+
188
+
</td>
189
+
</tr>
190
+
<tr>
191
+
<td>
192
+
193
+
```typescript
194
+
max: number;
195
+
```
196
+
197
+
</td>
198
+
<td>
199
+
200
+
Maximum value of the Slider. It is equal to `maximumValue` and has the same default if not set.
201
+
202
+
</td>
203
+
</tr>
204
+
</table>
205
+
115
206
## Roadmap and Progress
116
207
117
208
There's a Project board available [here](https://github.com/callstack/react-native-slider/projects/1) which contains all reported issues organized into columns regarding their status.
0 commit comments