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
Javascript :: get element attribute jquery 
Javascript :: how to select default searchable dropdown value in jquery 
Javascript :: console log on html 
Javascript :: how to update react app 
Javascript :: js callback hell 
Javascript :: how to get bearer token in react 
Javascript :: how to delete an exact element of array 
Javascript :: vue radio checked if 
Javascript :: what does connect do in redux 
Javascript :: JavaScript substring Syntax 
Javascript :: how to get time zone difference date-fns 
Javascript :: string javascript concatenation 
Javascript :: react native flatlist flex direction 
Javascript :: js index to index 
Javascript :: empty javascript 
Javascript :: source code angular material LOGIN PAGE 
Javascript :: vue3 header 
Javascript :: send a message in every guild discord.js 
Javascript :: validator.js 
Javascript :: != javascript 
Javascript :: Declare and Initialize Arrays in javascript 
Javascript :: what is middleware in express js 
Javascript :: todo list javascript 
Javascript :: javascript string methods cheat sheet 
Javascript :: js standard global 
Javascript :: Remove all falsy values from an array 
Javascript :: jsonArray find 
Javascript :: For-each over an array in JavaScript 
Javascript :: modal javascript 
Javascript :: super keyword in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =