Spaces:
Running
Running
File size: 782 Bytes
5c05829 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import React from "react";
import { motion } from "framer-motion";
import { useInView } from "react-intersection-observer";
/**
* AnimatedSection
* Animates children (fade-in, slide-up) as they scroll into view.
* Usage:
* <AnimatedSection>...</AnimatedSection>
*/
const AnimatedSection = ({ children, className = "", ...rest }) => {
const [ref, inView] = useInView({
triggerOnce: true,
threshold: 0.15,
});
return (
<motion.section
ref={ref}
initial={{ opacity: 0, y: 48 }}
animate={inView ? { opacity: 1, y: 0 } : {}}
transition={{ duration: 0.65, ease: "easeInOut" }}
className={className}
{...rest}
>
{children}
</motion.section>
);
};
export default AnimatedSection; |