Modal.js
framer-motion 라이브러리를 이용하여 이미지가 opacity 0->1 으로 변화하고 상단에서 아래로 떨어지도록 했다.
import React from "react";
import styled from "styled-components";
import { motion } from "framer-motion";
import Chatroom from "./Chatroom";
const Modal = ({ selectedImg, setSelectedImg, user }) => {
const handleClick = (e) => {
// console.log(e.target.classList);
if (e.target.classList.contains("backdrop")) {
setSelectedImg(null);
}
};
return (
<Backdrop
className="backdrop"
onClick={handleClick}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
// transition={{ duration: 1 }}
>
<MainImg
src={selectedImg.url}
alt="enlarged img"
initial={{ y: "-100vh" }}
animate={{ y: 0 }}
/>
{user ? <Chatroom user={user} selectedImgId={selectedImg.id} /> : null}
</Backdrop>
);
};
도움 받은 사이트
motion library with react: www.framer.com/motion/
visible effect: stackoverflow.com/questions/3331353/transitions-on-the-css-display-property
Scroll effect: www.w3schools.com/howto/tryit.asp?filename=tryhow_js_scroll_to_top
Smooth scroll:
www.w3schools.com/howto/tryit.asp?filename=tryhow_css_smooth_scroll
stackoverflow.com/questions/55472649/how-to-change-scroll-behavior-e-g-speed-acceleration-on-website
사진 크롤링 다운: hogni.tistory.com/81
'Projects > JStargram_2021' 카테고리의 다른 글
4일차 CSS/기능 리팩토링 및 배포 완료 (0) | 2021.04.09 |
---|---|
3일차 파이어베이스 로그인/로그아웃 및 채팅 구현 (0) | 2021.04.09 |
1일차 셋업/기본 로직 구현 (0) | 2021.04.08 |