Free Lottie Animation Files, Tools & Plugins - LottieFiles
The world’s largest online platform for the world’s smallest animation format for designers, developers, and more. Access Lottie animation tools and plugins for Android, iOS, and Web.
lottiefiles.com
귀여운 애니메이션 요소들을 넣어 우리의 웹사이트를 더욱 풍요롭게 만들어보자!
1. lottie-web라이브러리 설치
https://github.com/airbnb/lottie-web
GitHub - airbnb/lottie-web: Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io
Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/ - GitHub - airbnb/lottie-web: Render After Effects animations natively on Web, Android a...
github.com
2. 마음에 드는 파일 다운로드

json파일을 다운받고 우리의 프로젝트에 파일을 만들어서 넣어주자
import React , {useEffect, useRef} from "react";
import styled from "styled-components";
import lottie from "lottie-web";
import Color from "../../shared/Color";
import { style } from "@material-ui/system";
const GetTreasureLottie = ()=>{
//lottie
const likecontainer = useRef();
useEffect(()=>{
lottie.loadAnimation({
container: likecontainer.current,
renderer: 'svg',
loop: false,
autoplay:true,
animationData:require("./congratulation.json")
})
},[])
return(
<Wrapper>
<NoMore ref={likecontainer}></NoMore>
</Wrapper>
)
}
const Wrapper = styled.div`
`;
const NoMore = styled.div`
width: 100%;
height: 100%;
margin: 0 auto;
position: absolute;
margin: 0 auto;
z-index: 1000;
`;
const Arrow = styled.div`
position: absolute;
bottom: 100px;
left: 40%;
width: 80px;
height: 80px;
margin: 0 auto;
`;
const Text= styled.div`
`;
export default GetTreasureLottie;
로티 컴포넌트를 만들어서 ref로 지정해주고 이렇게 사용한다.
그리고 이 컴포넌트는 필요한 페이지에서 갖다쓰면된다.
참 쉽죠잉?
'WEB > REACT' 카테고리의 다른 글
[REACT] React swiper에 image lazy loading 적용하기/ intersection observer (0) | 2021.09.08 |
---|---|
[REACT] Intersection Observer (0) | 2021.09.08 |
[REACT] 리액트 메모에 대한 공부 링크 (0) | 2021.09.01 |
[REACT] react-ga로 리액트 프로젝트에 google analytics 적용하기 (0) | 2021.08.27 |
[REACT] 책 검색 자동완성기능 구현 (0) | 2021.08.26 |