Update components/in-view-div.tsx
This commit is contained in:
parent
97bc0acc1e
commit
4ea0e024ab
|
|
@ -0,0 +1,18 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useRef } from "react";
|
||||||
|
import { useInView } from "framer-motion";
|
||||||
|
|
||||||
|
export function InViewDiv({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: { children: React.ReactNode } & any) {
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
let isInView = useInView(containerRef, { once: true, amount: 0.4 });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={containerRef} {...props}>
|
||||||
|
{isInView ? children : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue