-
Notifications
You must be signed in to change notification settings - Fork 11
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
[1주차] 최지원 미션 제출합니다. #3
base: master
Are you sure you want to change the base?
Changes from 1 commit
2174809
3556734
1434121
8ec025d
e3313a3
a254567
3152ab0
4de67aa
8f7e29b
c08b6fa
86260ea
3d0989b
ca4e76e
3d044fe
28d46e6
970222b
cd12e36
780ce6d
a8f23ca
eb9f93e
9ef7e0e
f6d8336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,9 +148,26 @@ const showMessage = document.querySelector(".show-input"); // 입력창 열고 | |
|
||
// 입력창 열고 닫기 함수 | ||
const toggleForm = () => { | ||
form.style.display = form.style.display === "none" ? "flex" : "none"; | ||
showMessage.innerHTML = | ||
form.style.display === "none" ? "입력창 불러오기" : "입력창 다시닫기"; | ||
if (form.classList.contains("show")) { | ||
form.classList.remove("show"); | ||
form.classList.add("hide"); | ||
|
||
form.addEventListener( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. toggleForm 함수가 실행될 때마다 animationend 이벤트 핸들러가 새로 추가되도록 코드가 작성되어있는 부분을 수정하면 좋을 것 같아요! ddEventListener()의 3번째 파라미터로 { once : true } 전달해 주어서, 이벤트가 발생할 때 한 번만 동작하게 되긴 하지만, 때문에 이 방식보다 { once: true } 옵션을 쓰지 않고, ` // 단순히 클래스만 토글하도록!! const toggleForm = () => { // 이벤트 리스너 초기에 1번만 등록!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정방향 코드까지 너무 감사드립니다!! 처음에 클래스 토글까지 구현한 상태에서 애니메이션을 추가하여 한번에 쓰려하다 보니 불필요한 동작이 일어나게 되는 것까지 고려하지 못한 것 같습니다. ㅜㅜ 한 함수에서 담당하는 기능이 최소화되도록 분리하여 쓰는 습관을 길러야겠다는 생각이 많이 듭니다. |
||
"animationend", | ||
() => { | ||
form.style.display = "none"; | ||
form.classList.remove("hide"); | ||
}, | ||
{ once: true } | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 입력창을 열고 닫을 때 애니메이션을 적용한 디테일 챙기는 부분 정말 좋네요! |
||
showMessage.innerHTML = "입력창 불러오기"; | ||
} else { | ||
form.style.display = "flex"; | ||
form.classList.remove("hide"); | ||
form.classList.add("show"); | ||
|
||
showMessage.innerHTML = "입력창 다시닫기"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. animationend라는 이벤트 리스너 타입을 활용하여 UI를 신경 쓴 부분이 인상깊습니다. 저는 처음 본 방법이라 신기하고, JS로 어느정도 수준의 UI까지 활용가능할 수 있는지 호기심이 생겼습니다. |
||
} | ||
}; | ||
|
||
// 이벤트 리스너 등록 및 기존 데이터 불러오기 함수 | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -55,6 +55,29 @@ main { | |||
justify-content: space-between; | ||||
} | ||||
|
||||
@keyframes slideDownFadeIn { | ||||
from { | ||||
opacity: 0; | ||||
transform: translateY(-20px); /* 위에서 아래로 */ | ||||
} | ||||
to { | ||||
opacity: 1; | ||||
transform: translateY(0); /* 제자리 */ | ||||
} | ||||
} | ||||
|
||||
@keyframes slideUpFadeOut { | ||||
from { | ||||
opacity: 1; | ||||
transform: translateY(0); | ||||
} | ||||
|
||||
to { | ||||
opacity: 0; | ||||
transform: translateY(-20px); | ||||
} | ||||
} | ||||
|
||||
.input-box { | ||||
width: 50%; | ||||
height: 1.875rem; | ||||
|
@@ -65,6 +88,15 @@ main { | |||
padding: 0 0.625rem; | ||||
} | ||||
|
||||
.input-box.show { | ||||
display: flex; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .input-box에서 display: flex를 설정한 후, .input-box.show에도 다시 display: flex를 설정되고 있어요. 이부분은 없애도 좋을 것 같아요
Suggested change
|
||||
animation: slideDownFadeIn 0.3s ease-out forwards; | ||||
} | ||||
|
||||
.input-box.hide { | ||||
animation: slideUpFadeOut 0.3s ease-out forwards; | ||||
} | ||||
|
||||
input { | ||||
width: 70%; | ||||
border: transparent; | ||||
|
@@ -116,7 +148,7 @@ ul { | |||
} | ||||
|
||||
footer { | ||||
width: 12.5rem; | ||||
width: 14rem; | ||||
display: flex; | ||||
flex-direction: row; | ||||
justify-content: space-between; | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런식으로 스타일을 통해서 관리하는 것도 좋지만 입력창의 상태(열림/닫힘)를 명확하게 추적하기 위해 boolean 변수로 상태를 관리하여 여닫는것도 유지보수하기엔 더 편하니까 한번 사용해봐도 좋을 것 같아요 :)_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클래스명은 워낙 지정하기 나름이라 혼동할 수도 있고, html/css에서 변경될 가능성도 있어 확실히 클래스 변경에 의존하는 것보다는 말씀해주신 것이 훨씬 직관적이고 혼란을 줄일 수 있겠다는 생각이 듭니다! 좋은 의견 주셔서 감사합니다☺️