Development/React.js

[React] Styled-Components를 이용한 애니메이션

moretz0921 2022. 4. 30. 00:48

애니메이션, Css로 제어
useEffect에서 setInterval 작업

 

const boxAnimation = keyframes`
  0% {
    left: 20px;
    background: red;
  }
  16.6666667% {
    left: 420px;
    background: orange;
  }
  33.3333333% {
    left: 20px;
    background: yellow;
  }
  50% {
    left: 420px;
    background: green;
  }
  66.6666667% {
    left: 20px;
    background: blue;
  }
  83.3333333% {
    left: 420px;
    background: navy;
  }
  100% {
    left: 20px;
    background: purple;
  }
`; 

const Box = styled.div`
  width: 100px;
  height: 100px;
  background: red;
  border-radius: 0%;
  position: absolute;
  top: 20px;
  left: 20px;
  animation: ${boxAnimation} 3s 0s infinite linear alternate;
`;

 

 

출처

https://github.com/AseemWangoo/expriments_with_react/blob/master/src/components/Fader/Fader.js

 

GitHub - AseemWangoo/expriments_with_react: Experiments with React

Experiments with React. Contribute to AseemWangoo/expriments_with_react development by creating an account on GitHub.

github.com

 

https://kjwsx23.tistory.com/625

 

[React] Styled-Components를 이용한 애니메이션

발단 이상형 월드컵을 구현하다가, 각 아이템을 선택했을 때 밋밋하게 사진이 바뀌는 것이 마음에 안들어서, 애니메이션 효과를 주려고 했다. 권장하는 방법 styled-components에서 특정 이벤트 시

kjwsx23.tistory.com

 

https://velog.io/@cinephile/%EB%A6%AC%EC%95%A1%ED%8A%B8-%EA%B8%B0%EC%B4%88%EB%B0%98-4-1-keyframes

 

[리액트 기초반] 4주차 - keyframes

animation에서 사용하는 속성 혹은 animation에 주는 규칙. 특정한 구간에서 특정한 효과를 적용하는 기능이다. 영상편집시 사용하는 키프레임과 비슷한 개념이라고 생각하자.

velog.io

 

'Development > React.js' 카테고리의 다른 글

Next.js의 Image를 사용하기  (0) 2022.04.30
[REACT] 리액트에서 줄바꿈 처리  (0) 2022.04.30
tab 구현하기  (0) 2022.04.27
[React] 조건부 렌더링, 활용하는 방법  (0) 2022.04.26
React Api key값 관리하기 (.env)  (0) 2022.04.17