Skip to content

Commit d27311e

Browse files
committed
update readme
1 parent 19ca989 commit d27311e

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ Hey, here's what you get with this slider:
1515
- Comes with a handy number input for when you need to be precise
1616
- Optional units display (°, px, %, etc.) right next to the number input
1717

18+
## How Cyclic Wrapping Works
19+
20+
When a value exceeds the maximum or falls below the minimum:
21+
22+
- **Values above max:** Wrap around to min + (value % max)
23+
- Example: With range 0-360, a value of 370 becomes 10
24+
- Example: With range 100-200, a value of 210 becomes 10 (210 % 200)
25+
26+
- **Values below min:** The component handles wrapping for values below the minimum
27+
28+
This cyclic behavior makes the slider perfect for:
29+
30+
- Angles (0-360 degrees)
31+
- Hue values in HSL color (0-360)
32+
- Time selection (hours, minutes)
33+
- And any other values that should wrap around at boundaries
34+
1835
## Installation
1936

2037
```bash
@@ -129,6 +146,53 @@ The component is versatile and can be used for various cyclic values:
129146
- **Clock Control:** 1-12 hours or 0-59 minutes
130147
- **Day of Week:** 0-6 for days of the week
131148
- **Month Selector:** 1-12 for months of the year
149+
- **Temperature Range:** -50 to 50 degrees
150+
- **Rotation:** -180 to 180 degrees
151+
152+
### Custom Range Examples
153+
154+
```jsx
155+
// Standard range (min=0, max>0)
156+
<CyclicSlider
157+
value={5}
158+
min={0}
159+
max={10}
160+
step={1}
161+
label="Standard Range"
162+
onChange={handleChange}
163+
/>
164+
165+
// Positive range (min>0, max>min)
166+
<CyclicSlider
167+
value={110}
168+
min={100}
169+
max={200}
170+
step={1}
171+
label="Positive Range"
172+
onChange={handleChange}
173+
/>
174+
175+
// Range with negative min (min<0, max>0)
176+
<CyclicSlider
177+
value={0}
178+
min={-180}
179+
max={180}
180+
step={1}
181+
label="Rotation (-180° to 180°)"
182+
unit="°"
183+
onChange={handleChange}
184+
/>
185+
186+
// Fractional step values
187+
<CyclicSlider
188+
value={2.5}
189+
min={0}
190+
max={10}
191+
step={0.5}
192+
label="Fractional Steps"
193+
onChange={handleChange}
194+
/>
195+
```
132196

133197
## Development
134198

0 commit comments

Comments
 (0)