Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react animate on scroll

import { motion, useAnimation } from "framer-motion";
import { useInView } from "react-intersection-observer";
import { useEffect } from "react";

const boxVariant = {
  visible: { opacity: 1, scale: 1, transition: { duration: 0.5 } },
  hidden: { opacity: 0, scale: 0 }
};

const Box = ({ num }) => {

  const control = useAnimation();
  const [ref, inView] = useInView();

  useEffect(() => {
    if (inView) {
      control.start("visible");
    } else {
      control.start("hidden");
    }
  }, [control, inView]);

  return (
    <motion.div
      className="box"
      ref={ref}
      variants={boxVariant}
      initial="hidden"
      animate={control}
    >
      <h1>Box {num} </h1>
    </motion.div>
  );
};

export default function App() {
  return (
    <div className="App">
      <Box num={1} />
      <Box num={2} />
      <Box num={3} />
    </div>
  );
}
Comment

react animate on scroll

<ScrollAnimation animateIn='flipInY'
  animateOut='flipOutX'>
  <h1>
    animateOut
  </h1>
</ScrollAnimation>
Comment

react scroll animation

import "animate.css/animate.min.css";
Comment

PREVIOUS NEXT
Code Example
:: get element attribute jquery 
Javascript :: how to select default searchable dropdown value in jquery 
::  
Javascript ::  
Javascript ::  
Javascript ::  
Javascript :: discord js check every x minutes 
::  
:: what is react reveal 
Javascript :: loop into array javascript 
Javascript :: format function shift the date one day up date-fns 
::  
Javascript ::  
::  
Javascript ::  
Javascript ::  
Javascript ::  
Javascript ::  
:: text slider in react js 
Javascript :: debug bar laravel unninstall 
Javascript ::  
:: remove first character javascript 
Javascript ::  
Javascript ::  
::  
::  
Javascript :: return value 
Javascript :: enzyme airnb 
Javascript ::  
:: side effect, useEffect 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =