Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ 2주차 기본/심화/생각 과제 ] 웨비의 사진관 😋 가계부 💸 #2

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
dce3223
🎨 실습
hae2ni Oct 17, 2023
df5d69e
Merge branch 'week1' of https://github.com/DO-SOPT-WEB/HyeinKwon into…
hae2ni Oct 17, 2023
c1c28cc
🍱 data.js 추가
hae2ni Oct 17, 2023
5f4973f
🎨 index.js 추가
hae2ni Oct 17, 2023
fe862b1
✨ 1.a 이미지 호버시 어둡게 처리되며 제목 사진 나타남 구현
hae2ni Oct 17, 2023
7a89d46
💄 title, summary 꾸미기
hae2ni Oct 17, 2023
c90b73f
✨ 스크롤에 따라 투명도 다르게
hae2ni Oct 17, 2023
84b6da4
⚡️ 코드 깔끔하게 정리
hae2ni Oct 17, 2023
5d223ce
🍱 상수 데이터 추가
hae2ni Oct 19, 2023
22646ca
🎨 index.js 연결
hae2ni Oct 19, 2023
971f235
📝 주석 수정
hae2ni Oct 19, 2023
778df50
🔥 불필요 코드 삭제
hae2ni Oct 19, 2023
b91b555
🔥 불필요 코드 삭제
hae2ni Oct 19, 2023
e3b8eab
✨ 과제 2 1, 2 번 마무리
hae2ni Oct 19, 2023
df26c1e
🎨 chckbox checked 표시 지우기
hae2ni Oct 20, 2023
19e6012
🎨 3,4번 기본
hae2ni Oct 20, 2023
d7ce397
💄 hidden 요소 추가
hae2ni Oct 20, 2023
73dacb3
🎨 modal 일단 html에 박아놓기
hae2ni Oct 20, 2023
7e8630c
💄 modal 꾸미기
hae2ni Oct 20, 2023
8f3e1b1
🎨 modal radio 버튼으로 변경 id 추가
hae2ni Oct 21, 2023
e66a1c8
✨ 5번 a,b,c,e 구현
hae2ni Oct 21, 2023
03c93b8
💄 css 추가
hae2ni Oct 21, 2023
448be92
✨ 모달 금액 TOTAL 반영
hae2ni Oct 21, 2023
8239ecd
✨ 5.d 완료
hae2ni Oct 21, 2023
71f8e55
🎨 코드 줄 바꿈
hae2ni Oct 21, 2023
32dbb97
🍱 Data 추가
hae2ni Oct 24, 2023
bcdee23
💄 제목 설명 가운데 정렬
hae2ni Oct 24, 2023
86673a6
🎨 1번과제 심화 1번
hae2ni Oct 24, 2023
e6342ec
✨ preview 버튼 추가
hae2ni Oct 24, 2023
65a1171
🥅 심화 1번 자잘한 에러 제거
hae2ni Oct 25, 2023
61ba336
✨ 심화 2번 완료
hae2ni Oct 25, 2023
9d95a30
💄 모달 변경
hae2ni Oct 25, 2023
aa21ba7
✨ 심화 2.a
hae2ni Oct 25, 2023
b96648d
✨ 심화 b 금액이 아닌 숫자 입력시 alert
hae2ni Oct 25, 2023
8a2badf
✨ modal 뒷 배경 어둡게
hae2ni Oct 25, 2023
0ba969e
💄 심화 3.b 모달 아래에서 위로 올라오기
hae2ni Oct 25, 2023
3f7860f
✨ 심화 5번
hae2ni Oct 25, 2023
2016021
💄 모달 이쁘게 꾸미기
hae2ni Oct 25, 2023
fb51280
💄 삭제 모달 추가
hae2ni Oct 25, 2023
5b78f1d
💄 리스트 삭제 모달
hae2ni Oct 26, 2023
26b2f87
✨ 심화 1번 완료
hae2ni Oct 26, 2023
6a65a53
💄 카테고리 관리로 이동하는 버튼 추가
hae2ni Oct 26, 2023
f5ba2b8
💄 카테고리 페이지 꾸미기
hae2ni Oct 26, 2023
75718ac
💄 카테고리 페이지 꾸미기
hae2ni Oct 26, 2023
4a93378
✨ 심화 4번 2,3,4,6
hae2ni Oct 26, 2023
3eca375
✨ 심화 4번 완료
hae2ni Oct 26, 2023
15ebba8
♻️ 시멘틱 태그 추가
hae2ni Oct 26, 2023
784dd85
Merge branch 'main' of https://github.com/DO-SOPT-WEB/HyeinKwon into …
hae2ni Oct 26, 2023
86d78e9
📝 생각과제
hae2ni Oct 26, 2023
63b2840
🚑 오류 고침
hae2ni Oct 26, 2023
1013308
🚑 오류 수정
hae2ni Oct 26, 2023
06896e1
♻️ 중복되는 코드 지우고 필여한 부분 넣기
hae2ni Oct 30, 2023
cd65a5a
♻️ 코드리뷰 반영
hae2ni Nov 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions assign1/DATA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const DATA = [
{ title: "꽃속의 웰코", summary: "이뿌지!!" },
{ title: "멀보니웰코", summary: "날씨 조타!" },
{ title: "눈웃음웰코", summary: "모야! 햇빛 죠아!" },
Comment on lines +1 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 이거 객체로 빼쥰거 좋은 것 같아 넘굿굿!!!!!

{
title: "잠자는 말티즈으",
summary:
"말티즈가잠을자고있어요말티즈가잠을자고있어요말티즈가잠을자고있어요",
},
{ title: "사모예드가 당당티비!", summary: "아뇽! 나는 당당한 사모예에드!" },
{ title: "졸림 강얼지", summary: "졸려티비..." },
{
title: "나 귀엽지?",
summary:
"너무 귀엽구 사랑스러워 너가 다행 핑크 옷 입은 강아지가 만세를 하고 웃다니 세상을 다 가질 것 같아",
},
{
title: "우리는 두마리!",
summary:
"강아지가 두마리라니 더 사랑스럽고 너무 사랑스럽고 너무 귀엽다ㅠㅠ 아 진짜 귀엽다 어떡해,,,",
},
{ title: "무념무상", summary: "...졸려요" },
{ title: "너...너...", summary: "내가 가지고 만다" },
];

export default DATA;
Comment on lines +25 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나나 모듈에 대해서 잘 몰랐는데
export default DATA; 이렇게 하면 import로 해서 다른 JS와 연결한 후에
DATA안에 상수 값을 따로 넣어주니까 잘 구분되서 가독성을 올리려는거지?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞습니다!

141 changes: 84 additions & 57 deletions assign1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>📷먀먀먀먀먀 혠찡의 사진관티비 꺅📷</title>
<link rel="stylesheet" href="./style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="module" src="./DATA.js"></script>
</head>
<body>
<header id="main_header"><h1>혠찡의 사진관티비 꺅</h1></header>
<main>
<section class="scroll" id="preview">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/f569fe59-db2c-49b0-aea3-4c4d4de9a909"
alt="꽃속에서웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/04e42574-2bc0-4645-9a29-8149f6d81d30"
alt="웃고있는웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/643e8286-a1a0-430f-ad90-ce475fe78377"
alt="바라본당" />
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2F2b%2Fb2%2F10%2F2bb210388eb9d005456df3af578745c2.jpg&type=ofullfill340_600_png"
alt="어디바" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/86f38ede-d8f0-42f2-a888-880b0c1f135c"
alt="크리스마스냥이" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2F20150521_189%2Fqparass_1432179692522fUKxm_JPEG%2FNaverBlog_20150521_124131_17.jpg&type=ofullfill340_600_png"
alt="기염댕" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjExMjZfMTYz%2FMDAxNjY5NDY0MzE4Mzkx.dZWZtEr4da2urtDMN1rze3qSYHXtAbzIo_yV46HkJcog.OFlpulUKMQ_KL0jL1Xt-cn5dyq9SOXkoqwcIPX8LPqwg.JPEG.eunji2867%2F5787b9d7145ab7b526e05e896973590c.jpg&type=a340"
alt="만세링" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fcafefiles.naver.net%2F20150523_100%2Fjjun02026_1432388973865UnATH_JPEG%2F%25B8%25BB%25B8%25AE5_%25282%2529.JPG&type=sc960_832"
alt="뒹굴" />
<section id="preview">
<button type="button" id="toLeft">&lt;</button>
<article id="img_wrapper" class="scroll">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/f569fe59-db2c-49b0-aea3-4c4d4de9a909"
alt="꽃속에서웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/04e42574-2bc0-4645-9a29-8149f6d81d30"
alt="웃고있는웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/643e8286-a1a0-430f-ad90-ce475fe78377"
alt="바라본당" />
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2F2b%2Fb2%2F10%2F2bb210388eb9d005456df3af578745c2.jpg&type=ofullfill340_600_png"
alt="어디바" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/86f38ede-d8f0-42f2-a888-880b0c1f135c"
alt="크리스마스냥이" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2F20150521_189%2Fqparass_1432179692522fUKxm_JPEG%2FNaverBlog_20150521_124131_17.jpg&type=ofullfill340_600_png"
alt="기염댕" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjExMjZfMTYz%2FMDAxNjY5NDY0MzE4Mzkx.dZWZtEr4da2urtDMN1rze3qSYHXtAbzIo_yV46HkJcog.OFlpulUKMQ_KL0jL1Xt-cn5dyq9SOXkoqwcIPX8LPqwg.JPEG.eunji2867%2F5787b9d7145ab7b526e05e896973590c.jpg&type=a340"
alt="만세링" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fcafefiles.naver.net%2F20150523_100%2Fjjun02026_1432388973865UnATH_JPEG%2F%25B8%25BB%25B8%25AE5_%25282%2529.JPG&type=sc960_832"
alt="뒹굴" />
</article>
<button type="button" id="toRight">&gt;</button>
</section>

<nav>
Expand All @@ -56,38 +62,58 @@ <h1>클릭하면 이동해요!</h1>
<h2 class="section_title">🐶아기멈무🐶</h2>
</div>
<article class="first_pic_wrapper">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/f569fe59-db2c-49b0-aea3-4c4d4de9a909"
alt="꽃속에서웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/643e8286-a1a0-430f-ad90-ce475fe78377"
alt="" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/04e42574-2bc0-4645-9a29-8149f6d81d30"
alt="웃고있는웰코" />
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/f569fe59-db2c-49b0-aea3-4c4d4de9a909"
alt="꽃속에서웰코" />
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2F2b%2Fb2%2F10%2F2bb210388eb9d005456df3af578745c2.jpg&type=ofullfill340_600_png"
alt="어디바" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2F20150521_189%2Fqparass_1432179692522fUKxm_JPEG%2FNaverBlog_20150521_124131_17.jpg&type=ofullfill340_600_png"
alt="기염댕" />
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjExMjZfMTYz%2FMDAxNjY5NDY0MzE4Mzkx.dZWZtEr4da2urtDMN1rze3qSYHXtAbzIo_yV46HkJcog.OFlpulUKMQ_KL0jL1Xt-cn5dyq9SOXkoqwcIPX8LPqwg.JPEG.eunji2867%2F5787b9d7145ab7b526e05e896973590c.jpg&type=a340"
alt="만세링" />
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2Fcc%2Fb2%2Ff2%2Fccb2f2e4efcd7c98ba8d0ebf9693a158.jpg&type=a340"
alt="두마리지롱" />
<img
class="media_small"
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2Fb9%2F21%2F55%2Fb9215568498d0017edf37d607b086dd5.jpg&type=sc960_832"
alt="어디가" />
<img
class="media_small"
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjA4MTVfMTUg%2FMDAxNjYwNTMwNDAxMTgw.cwvPNFHDd2kqQS5kB4y2tItlt7rwPdUvALarWkHEgwcg.7WpqASll1KKH9BvsSUri5elJG-vNRGwQ3yocRmiyz4wg.JPEG.summervacation1%2FIMG_8776.JPG&type=ofullfill340_600_png"
alt="사과먹구싶다" />
<div class="first_section_pic">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/f569fe59-db2c-49b0-aea3-4c4d4de9a909"
alt="꽃속에서웰코" />
</div>
<div class="first_section_pic">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/643e8286-a1a0-430f-ad90-ce475fe78377"
alt="멀보니웰코" />
</div>
<div class="first_section_pic">
<img
src="https://github.com/DO-SOPT-WEB/HyeinKwon/assets/100409061/04e42574-2bc0-4645-9a29-8149f6d81d30"
alt="웃고있는웰코" />
</div>
<div class="first_section_pic">
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMTA5MzBfMTYz%2FMDAxNjMyOTQxNTMyNTQ3.V9Hj_HKiiw5QHhgJexI9XzMejk_8JQkJjHu7SPIcEYUg.tH2oDp1qOWtg_L1uDIDkv8SGAuJ-lIwDOaWBv0-1jyIg.JPEG.jisu9610042%2FIMG_6965.JPG&type=sc960_832"
alt="잠든 말티쥬" />
</div>
<div class="first_section_pic">
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2F2b%2Fb2%2F10%2F2bb210388eb9d005456df3af578745c2.jpg&type=ofullfill340_600_png"
alt="어디바" />
</div>
<div class="first_section_pic">
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2F20150521_189%2Fqparass_1432179692522fUKxm_JPEG%2FNaverBlog_20150521_124131_17.jpg&type=ofullfill340_600_png"
alt="기염댕" />
</div>
<div class="first_section_pic">
<img
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjExMjZfMTYz%2FMDAxNjY5NDY0MzE4Mzkx.dZWZtEr4da2urtDMN1rze3qSYHXtAbzIo_yV46HkJcog.OFlpulUKMQ_KL0jL1Xt-cn5dyq9SOXkoqwcIPX8LPqwg.JPEG.eunji2867%2F5787b9d7145ab7b526e05e896973590c.jpg&type=a340"
alt="만세링" />
</div>
<div class="first_section_pic">
<img
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2Fcc%2Fb2%2Ff2%2Fccb2f2e4efcd7c98ba8d0ebf9693a158.jpg&type=a340"
alt="두마리지롱" />
</div>
<div class="first_section_pic">
<img
class="media_small"
src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2F736x%2Fb9%2F21%2F55%2Fb9215568498d0017edf37d607b086dd5.jpg&type=sc960_832"
alt="어디가" />
</div>
<div class="first_section_pic">
<img
class="media_small"
src="https://search.pstatic.net/common/?src=http%3A%2F%2Fblogfiles.naver.net%2FMjAyMjA4MTVfMTUg%2FMDAxNjYwNTMwNDAxMTgw.cwvPNFHDd2kqQS5kB4y2tItlt7rwPdUvALarWkHEgwcg.7WpqASll1KKH9BvsSUri5elJG-vNRGwQ3yocRmiyz4wg.JPEG.summervacation1%2FIMG_8776.JPG&type=ofullfill340_600_png"
alt="사과먹구싶다" />
</div>
</article>
</section>

Expand Down Expand Up @@ -166,5 +192,6 @@ <h2 class="section_title">🐣다른아가들🐣</h2>
<footer>
<h1>귀여워찌??</h1>
</footer>
<script type="module" src="index.js"></script>
</body>
</html>
97 changes: 97 additions & 0 deletions assign1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import DATA from "./DATA.js";

const $ = (selector) => document.querySelector(selector);
const $$ = (selector) => document.querySelectorAll(selector);
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드에서 $ 를 쓴게 안보이는데 따로 의미가 있을까?? 내가 못찾은 거라면 미안해..,.😓

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래 쓰려고 하다가 첨에 잘 안되기두 했구 오히려 더더 헷갈려서ㅠ 일단 보류해 두었으,,,,, 너무 헷갈리게 id나 class이름을 지은 것 같아ㅠ

Comment on lines +3 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나두 이게 어떤 의미인지 궁금해!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 선택자 중복이라 함수로 따로 빼준거!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중복된 선택자들에게 다 적용하는 함수를 만들어주려면 함수명으로 $를 쓴다는 말인가?!


// 1.a , b
const firstImages = document.querySelectorAll(".first_section_pic");

Comment on lines +6 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위랑 같은 맥락으로 요기를 그럼 $$로 쓸 수 있었던 것 아닌가?!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우웅 마자요!!! 근데 쓰다 안 쓰다보다 일단 안 쓰는게 나을 것 같아서 일차적으로는 안 썻으

//더보기 버튼 생성
const moreBtn = document.createElement("button");
moreBtn.classList.add("more_button");
moreBtn.innerText = "더보기";

firstImages.forEach((pic, index) => {
const h2 = document.createElement("h2");
h2.classList.add("title");
const p = document.createElement("p");
p.classList.add("summary");
const { title, summary } = DATA[index];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런게 바로 구조분해 할당이군요.. 지인짜 깔끔하다 ...


let moreBtnClicked = false;

pic.addEventListener("mouseover", function () {
pic.childNodes[1].classList.add("addTitle");
pic.classList.add("addTitle");
h2.innerText = title;

const div = document.createElement("div");
div.classList.add("title_summary_wrapper");
div.appendChild(h2);
p.innerText = summary;
div.appendChild(p);
pic.appendChild(div);

//심화 1번
const pHeight = p.clientHeight;
const summaryHeight = p.scrollHeight;

if (pHeight < summaryHeight) {
Comment on lines +35 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오옹 나는 p태그의 높이를 getComputedStyle(detail).height로 받아와서 구현했는데 이렇게도 할 수 있구나

div.appendChild(moreBtn);
!moreBtnClicked ? (moreBtn.style.display = "flex") : null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삼항연산자 쓰니까 되게 깔끔하네용.. 저기서 null은 아무런 동작을 하지 않는거야?
나는 if else가 아니라 if만 써야하는 상황에서 else에는 어떤 동작을 넣어줘야 하는건지를 몰라서 삼항연산자를 못 쓰고 있었거든...!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우웅!! 사실 if만 사용하는 부분에선 이항 연산자 사용해도 되긴 해용! 아니면 저렇게 null로?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오.. 조금 더 공부해봐야겠다! 또 하나 배워가용🫶

moreBtn.addEventListener("click", () => {
p.classList.replace("summary", "summaryAll");
moreBtn.style.display = "none";
});
}
moreBtn.addEventListener("click", () => {
p.classList.replace("summary", "summaryAll");
moreBtnClicked = true;
moreBtn.style.display = "none";
});
});
Comment on lines +47 to +52
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

심화과제는 못했지만
클릭하는 이벤트가 발생했을 때 summary가 summaryAll로 바뀌고
display가 none으로 더보기 창이 없어지는 건 이해가 되는데
moreBtnClicked = true; 라는 불린값은 어째서 들어가는 것인가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 요고 더보기 버튼이 눌렸었는지 안 눌렸는지 확인하려고 넣어둔 친구입니다!
그러니까 더보기 버튼을 addEventListener 로 click 이벤트를 줬을 때 더보기 버튼이 눌렸다! 라는 걸 표현해서 이후에 더보기 버튼이 처음처럼 사진에 마우스를 올리면 나타날 수 있도록 하려고 주었어요!


pic.addEventListener("mouseleave", function () {
pic.classList.remove("addTitle");
h2.innerText = "";
p.innerText = "";
p.classList.replace("summaryAll", "summary");
moreBtn.style.display = "none";
moreBtnClicked = false;
});
});

//2.a
const gotopBtn = document.getElementById("gotop_btn");
window.addEventListener("scroll", () => {
const scrollY = window.scrollY;
const maxScroll = document.body.clientHeight - window.innerHeight;
const opacity = scrollY / maxScroll;
gotopBtn.style.opacity = opacity;
});

//심화 2번
const preview = document.getElementById("preview");
const article = document.getElementById("img_wrapper");
const toLeft = document.getElementById("toLeft");
const toRight = document.getElementById("toRight");

toLeft.addEventListener("click", () => {
const articleWidth = article.scrollLeft;
Comment on lines +78 to +80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

화살표 함수 되게 잘쓴다..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 무슨 칭찬이야 너무 고맙군

const articleWidthh = article.scrollRight;
console.log(articleWidth, articleWidthh);
article.scrollTo({
left: articleWidth - 150,
behavior: "smooth",
});
});

toRight.addEventListener("click", () => {
const articleWidth = article.scrollLeft;
const articleWidthh = article.scrollRight;
console.log(articleWidth, articleWidthh);
article.scrollTo({
left: articleWidth + 150,
behavior: "smooth",
});
});
Loading