|
1 | 1 | <div align="center"> |
2 | 2 |
|
| 3 | + |
| 4 | + |
3 | 5 | # React UI ScrollSpy |
4 | 6 |
|
5 | 7 | [](https://npmjs.com/package/react-ui-scrollspy) |
|
11 | 13 |  |
12 | 14 |  |
13 | 15 |
|
14 | | -</div> |
15 | | - |
16 | | -Customizable and Simple `ScrollSpy` component for `react` with `TypeScript` support. |
17 | | - |
18 | 16 | Make sure you ⭐️ this [`repository`](https://github.com/pettiboy/react-ui-scrollspy) if you find it helpful or interesting :) |
19 | 17 |
|
| 18 | +</div> |
| 19 | + |
20 | 20 | ## ✨ Installation |
21 | 21 |
|
22 | 22 | ```bash |
@@ -79,7 +79,25 @@ import ScrollSpy from "react-ui-scrollspy"; |
79 | 79 | } |
80 | 80 | ``` |
81 | 81 |
|
82 | | -`NOTE:` See [`demo-app`](./demo-app/src/App.tsx) for example used [here](https://pettiboy.github.io/react-ui-scrollspy). |
| 82 | +## 📝 Notes |
| 83 | + |
| 84 | +Incase the ScrollSpy is not working the way you expected, you can try the following: |
| 85 | + |
| 86 | +- Reduce the value of [`scrollThrottle`](#-throttle). |
| 87 | + |
| 88 | +- If your page contains a `navbar` a `header` consider adding the following `CSS` |
| 89 | + |
| 90 | +```css |
| 91 | +html { |
| 92 | + scroll-padding-top: 120px; /* height of your navbar */ |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +- Try using [`offsets`](#-offsets). |
| 97 | + |
| 98 | +- Go through the [`Props`](#-props). |
| 99 | + |
| 100 | +- See [`demo-app`](./demo-app/src/App.tsx) for example used [here](https://pettiboy.github.io/react-ui-scrollspy). |
83 | 101 |
|
84 | 102 | ## 💡 Props |
85 | 103 |
|
@@ -117,11 +135,13 @@ import ScrollSpy from "react-ui-scrollspy"; |
117 | 135 |
|
118 | 136 | ### 🔧 Customize Attributes |
119 | 137 |
|
120 | | -| Attributes | Type | Description | Default | Required | |
121 | | -| :----------------- | :-------- | :------------------------------------------------------------------------------------------------------- | :-------------------- | :------- | |
122 | | -| `useDataAttribute` | `string` | To customize the string after `data-` | `"to-scrollspy-id"` | no | |
123 | | -| `activeClass` | `string` | To customize the `class` added when the `Element` in view | `"active-scroll-spy"` | no | |
124 | | -| `useBoxMethod` | `boolean` | Set to `false` if you want your spy to be active only if more than`50%` of that `div` is in the viewport | `true` | no | |
| 138 | +| Attributes | Type | Description | Default | Required | |
| 139 | +| :----------------- | :-------- | :-------------------------------------------------------------------------------------------------------- | :-------------------- | :------- | |
| 140 | +| `useDataAttribute` | `string` | To customize the string after `data-` | `"to-scrollspy-id"` | no | |
| 141 | +| `activeClass` | `string` | To customize the `class` added when the `Element` in view | `"active-scroll-spy"` | no | |
| 142 | +| `useBoxMethod` | `boolean` | Set to `false` if you want your spy to be active only if more than `50%` of that `div` is in the viewport | `true` | no | |
| 143 | + |
| 144 | +## |
125 | 145 |
|
126 | 146 | ## 📝 Authors |
127 | 147 |
|
|
0 commit comments