Skip to content

Commit 67bbb5c

Browse files
CXBoyySMAKSS
authored andcommitted
fix: update package version and readme file
1 parent 842ed67 commit 67bbb5c

File tree

3 files changed

+16
-4313
lines changed

3 files changed

+16
-4313
lines changed

Readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import useDetectScroll, {
4343

4444
The `useDetectScroll` hook takes an options object with the following properties:
4545

46+
- `target`: The target scrollable element from which to detect scroll direction and position (default: `window`, must be an `HTMLDivElement`).
4647
- `thr`: Threshold for scroll direction change detection (default: `0`, accepts only positive values).
4748
- `axis`: Defines the scroll axis (`"y"` or `"x"`, default: `"y"`).
4849
- `scrollUp`: Value returned when scrolling up (y-axis) or left (x-axis) (default: `"up"` for y-axis, `"left"` for x-axis).
@@ -74,6 +75,20 @@ const { scrollDir, scrollPosition } = useDetectScroll({ axis: Axis.X });
7475
// scrollPosition: { top, bottom, left, right }
7576
```
7677

78+
To use a custom scrollable element as a target rather than the default window:
79+
80+
```js
81+
const customElementRef = useRef<HTMLDivElement>(null);
82+
const [customElement, setCustomElement] = useState<HTMLDivElement>();
83+
useEffect(() => {
84+
if(customElementRef.current) {
85+
setHomepageElement(customElementRef.current);
86+
}
87+
}, [customElementRef])
88+
const scrollDir = useDetectScroll({target: customElement});
89+
console.log(scrollDir);
90+
```
91+
7792
## Contributing
7893

7994
Interested in making contributions to this project? Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and details.

0 commit comments

Comments
 (0)