domet 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Lightweight under the hood: a tight scroll loop and hysteresis for stable, flick
|
|
|
6
6
|
|
|
7
7
|
For the source code, check out the [GitHub](https://github.com/blksmr/domet).
|
|
8
8
|
|
|
9
|
-
## Installation
|
|
9
|
+
## Installation Requires React 18 or higher
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install domet
|
|
@@ -44,27 +44,27 @@ function Page() {
|
|
|
44
44
|
|
|
45
45
|
### Arguments
|
|
46
46
|
|
|
47
|
-
|
|
|
48
|
-
|
|
49
|
-
| `sectionIds` | `string[]` | Array of section IDs to track |
|
|
50
|
-
| `containerRef` | `RefObject<HTMLElement> \| null` | Scrollable container (defaults to
|
|
51
|
-
| `options` | `DometOptions` | Configuration options |
|
|
47
|
+
| Prop | Type | Default | Description |
|
|
48
|
+
|------|------|---------|-------------|
|
|
49
|
+
| `sectionIds` | `string[]` | — | Array of section IDs to track |
|
|
50
|
+
| `containerRef` | `RefObject<HTMLElement> \| null` | `null` | Scrollable container (defaults to window) |
|
|
51
|
+
| `options` | `DometOptions` | `{}` | Configuration options |
|
|
52
52
|
|
|
53
53
|
### Options
|
|
54
54
|
|
|
55
|
-
|
|
|
56
|
-
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
|------|------|---------|-------------|
|
|
57
57
|
| `offset` | `number` | `0` | Trigger offset from top in pixels |
|
|
58
58
|
| `offsetRatio` | `number` | `0.08` | Viewport ratio for trigger line calculation |
|
|
59
59
|
| `debounceMs` | `number` | `10` | Throttle delay in milliseconds |
|
|
60
60
|
| `visibilityThreshold` | `number` | `0.6` | Minimum visibility ratio (0-1) for section to get priority |
|
|
61
61
|
| `hysteresisMargin` | `number` | `150` | Score margin to prevent rapid section switching |
|
|
62
|
-
| `behavior` | `'smooth' \| 'instant' \| 'auto'` | `'auto'` | Scroll behavior.
|
|
62
|
+
| `behavior` | `'smooth' \| 'instant' \| 'auto'` | `'auto'` | Scroll behavior. 'auto' respects prefers-reduced-motion |
|
|
63
63
|
|
|
64
64
|
### Callbacks
|
|
65
65
|
|
|
66
|
-
|
|
|
67
|
-
|
|
66
|
+
| Prop | Type | Description |
|
|
67
|
+
|------|------|-------------|
|
|
68
68
|
| `onActiveChange` | `(id: string \| null, prevId: string \| null) => void` | Called when active section changes |
|
|
69
69
|
| `onSectionEnter` | `(id: string) => void` | Called when a section enters the viewport |
|
|
70
70
|
| `onSectionLeave` | `(id: string) => void` | Called when a section leaves the viewport |
|
|
@@ -73,10 +73,10 @@ function Page() {
|
|
|
73
73
|
|
|
74
74
|
### Return Value
|
|
75
75
|
|
|
76
|
-
|
|
|
77
|
-
|
|
76
|
+
| Prop | Type | Description |
|
|
77
|
+
|------|------|-------------|
|
|
78
78
|
| `activeId` | `string \| null` | ID of the currently active section |
|
|
79
|
-
| `activeIndex` | `number` | Index of the active section in
|
|
79
|
+
| `activeIndex` | `number` | Index of the active section in sectionIds (-1 if none) |
|
|
80
80
|
| `scroll` | `ScrollState` | Global scroll state |
|
|
81
81
|
| `sections` | `Record<string, SectionState>` | Per-section state indexed by ID |
|
|
82
82
|
| `sectionProps` | `(id: string) => SectionProps` | Props to spread on section elements |
|