Skip to content

Commit 23cd0f2

Browse files
authored
Merge pull request #16 from zJaaal/dev
Added documentation to the hooks
2 parents 795f475 + d7cca36 commit 23cd0f2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/lib/hooks/useDirection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import ScrollContext from "../context/ScrollContext";
33
import { Directions } from "../types";
44
import validateScrollValue from "../utils/validateScrollValue";
55

6+
/**
7+
* @description This hooks calculates the direction of your scroll
8+
* @returns direction: "UP" or "DOWN"
9+
*/
610
const useDirection = () => {
711
const scrollState = useContext(ScrollContext);
812
const [direction, setDirection] = useState(Directions.down);

src/lib/hooks/useProximity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import React, {
88
import ScrollContext from "../context/ScrollContext";
99
import validateScrollValue from "../utils/validateScrollValue";
1010

11+
/**
12+
* @description This hooks returns the proximity of the viewport from the component.
13+
* @param ref A reference to the HTMLElement
14+
* @returns A float value that represents the proximity to the component. The closer to 1 the closer is the middle of the screen from the component.
15+
*/
1116
const useProximity = (ref: RefObject<any>) => {
1217
const scrollState = useContext(ScrollContext);
1318

0 commit comments

Comments
 (0)