We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6d13744 commit c811934Copy full SHA for c811934
modules/hooks/useAnimateScroll.js
@@ -0,0 +1,26 @@
1
+import { useEffect, useRef } from "react";
2
+
3
+const useAnimateScroll = ({ method, options }) => {
4
+ if (!method) {
5
+ throw new Error("You need to provide a animateScroll method");
6
+ }
7
8
+ const containerRef = useRef();
9
10
+ useEffect(() => {
11
+ if (containerRef && containerRef.current) {
12
+ method({
13
+ container: containerRef.current,
14
+ ...options,
15
+ });
16
17
+ }, [
18
+ containerRef,
19
+ method,
20
+ options,
21
+ ]);
22
23
+ return containerRef;
24
+};
25
26
+export default useAnimateScroll;
0 commit comments