|
6 | 6 | [](https://raw.githubusercontent.com/pettiboy/react-ui-scrollspy/main/LICENSE) |
7 | 7 | [](https://github.com/pettiboy/react-ui-scrollspy/pulls) |
8 | 8 |
|
9 | | - |
10 | | - |
11 | | - |
| 9 | + |
| 10 | + |
| 11 | + |
12 | 12 |
|
13 | 13 | </div> |
14 | 14 |
|
|
24 | 24 | yarn add react-ui-scrollspy |
25 | 25 | ``` |
26 | 26 |
|
| 27 | +## 🎞 Demo |
| 28 | + |
| 29 | +### Try it your self [here](https://pettiboy.github.io/react-ui-scrollspy)! |
| 30 | + |
| 31 | + |
| 32 | + |
27 | 33 | ## ⚙️ Usage |
28 | 34 |
|
29 | 35 | 1. In your navigation component |
@@ -66,41 +72,43 @@ import ScrollSpy from "react-ui-scrollspy"; |
66 | 72 | } |
67 | 73 | ``` |
68 | 74 |
|
| 75 | +`NOTE:` See [`demo-app`](./demo-app/src/App.tsx) for example used [here](https://pettiboy.github.io/react-ui-scrollspy). |
| 76 | + |
69 | 77 | ## 💡 Props |
70 | 78 |
|
71 | | -### Children |
| 79 | +### 🔧 Children |
72 | 80 |
|
73 | 81 | | Attributes | Type | Description | Default | Required | |
74 | 82 | | :--------- | :---------- | :------------------------------------------------- | :------ | :------- | |
75 | 83 | | `children` | `ReactNode` | Each direct child `Element` should contain an `id` | - | yes | |
76 | 84 |
|
77 | | -### Refs |
| 85 | +### 🔧 Refs |
78 | 86 |
|
79 | 87 | | Attributes | Type | Description | Default | Required | |
80 | 88 | | :------------------------- | :------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------- | :------ | :------- | |
81 | 89 | | `navContainerRef` | MutableRefObject<br><HTMLDivElement \| null><br/> | `ref` to your navigation container containing items with `data-to-scrollspy-id` attributes | - | no | |
82 | 90 | | `parentScrollContainerRef` | MutableRefObject<br><HTMLDivElement \| null><br/> | If you want to spy only on a particular scrollable `container (Element)` then pass a ref of the same to this prop | - | no | |
83 | 91 |
|
84 | | -### Throlle |
| 92 | +### 🔧 Throlle |
85 | 93 |
|
86 | 94 | | Attributes | Type | Description | Default | Required | |
87 | 95 | | :--------------- | :------- | :--------------------------------------------------------------------------------------------------------------------- | :------ | :------- | |
88 | 96 | | `scrollThrottle` | `number` | In `milliseconds` to throttle the `onscroll` event. Lower the number, better the response, higher the performance cost | `300` | no | |
89 | 97 |
|
90 | | -### Callback |
| 98 | +### 🔧 Callback |
91 | 99 |
|
92 | 100 | | Attributes | Type | Description | Default | Required | |
93 | 101 | | :----------------- | :--------------------- | :-------------------------------------------------------------------------------------------------------------- | :------ | :------- | |
94 | 102 | | `onUpdateCallback` | `(id: string) => void` | Executes this function whenever you scroll to an `Element`, callback returns the `id` of that `Element` as well | - | no | |
95 | 103 |
|
96 | | -### Offsets |
| 104 | +### 🔧 Offsets |
97 | 105 |
|
98 | 106 | | Attributes | Type | Description | Default | Required | |
99 | 107 | | :------------- | :------- | :-------------------------------------------------------------------------------------------------------------- | :------ | :------- | |
100 | 108 | | `offsetTop` | `number` | Spy will be fired when it has been scrolled `offsetTop` beyond `50%` to the top of the containing element | `0` | no | |
101 | 109 | | `offsetBottom` | `number` | Spy will be fired when it has been scrolled `offsetBottom` beyond `50%` to the bottom of the containing element | `0` | no | |
102 | 110 |
|
103 | | -### Customize Attributes |
| 111 | +### 🔧 Customize Attributes |
104 | 112 |
|
105 | 113 | | Attributes | Type | Description | Default | Required | |
106 | 114 | | :----------------- | :------- | :----------------------------------------------------------- | :-------------------- | :------- | |
|
0 commit comments