-
Notifications
You must be signed in to change notification settings - Fork 88
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단계 - 상세 정보 & UI/UX 개선하기] 우디(류정우) 미션 제출합니다. #100
Changes from 1 commit
ef65a55
2a91b21
6d53e7a
ddf2b13
9e74943
68d012b
9963bd6
ca2c66e
18d5e93
4efe81a
1462656
b4cf9c2
bc20911
07f3a64
8e4a2f7
4cbda59
16ade29
eec09db
83a00a4
b3737f5
2de737a
ee35e61
2905d00
a4e0f34
165b569
4d02933
20ecb80
b7ea4de
71584a8
558abfa
632ef04
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 |
---|---|---|
|
@@ -30,21 +30,6 @@ class App { | |
this.render($target); | ||
|
||
this.bindEvent($target); | ||
|
||
document.addEventListener('renderMovies', async ({ detail: { query, page } }) => { | ||
if (query) { | ||
const { isError, data } = await this.movie.getFoundMovies(query, page); | ||
this.movieView.updateMovieListTitle(); | ||
this.movieView.addMovies(data); | ||
|
||
return; | ||
} | ||
|
||
const { isError, data } = await this.movie.getPopularMovies(page); | ||
this.movieView.updateMovieListTitle(query); | ||
this.movieView.addMovies(data); | ||
this.renderPopularMovies; | ||
}); | ||
} | ||
|
||
init($target) { | ||
|
@@ -54,20 +39,30 @@ class App { | |
this.movieView = new MovieView(this.$main); | ||
this.movieDetail = new MovieDetail($target); | ||
|
||
this.page = pageCounter(0); | ||
|
||
this.renderPopularMovies(this.page()); | ||
this.updateMovieView(); | ||
} | ||
|
||
render($target) { | ||
$target.insertAdjacentElement('beforeend', this.$main); | ||
} | ||
|
||
bindEvent($target) { | ||
$target.addEventListener('click', this.onClickHandler.bind(this)); | ||
$target.addEventListener('submit', this.onSubmitHandler.bind(this)); | ||
// $target.addEventListener('click', this.onClickHandler.bind(this)); | ||
// $target.addEventListener('submit', this.onSubmitHandler.bind(this)); | ||
|
||
window.addEventListener('scroll', this.onScrollHandler.bind(this)); | ||
|
||
document.addEventListener('renderMovies', ({ detail: { query, page } }) => | ||
this.updateMovieView(query, page) | ||
); | ||
} | ||
|
||
async updateMovieView(query = null, page = 1) { | ||
const { isError, data } = await this.movie.getMovies(query, page); | ||
if (isError) return; | ||
|
||
document.dispatchEvent(new CustomEvent('updateMovieListTitle', { detail: { query } })); | ||
this.movieView.addMovies(data); | ||
} | ||
|
||
onScrollHandler() { | ||
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. 여기서 스크롤 이벤트는 따로 분리하는게 좋겠어요 💭 |
||
|
@@ -88,18 +83,6 @@ class App { | |
} | ||
|
||
async onClickHandler({ target }) { | ||
if (target.id === 'logo') { | ||
if (this.isLoading) return; | ||
|
||
this.header.clearQuery(); | ||
|
||
this.page = pageCounter(0); | ||
|
||
this.renderPopularMovies(this.page()); | ||
|
||
return; | ||
} | ||
|
||
if (target.closest('.item')) { | ||
const { id } = target.closest('.item'); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,6 @@ class MovieView { | |
init() { | ||
this.$itemView.classList = 'item-view'; | ||
|
||
this.category = 'popular'; | ||
|
||
this.movieListTitle = new MovieListTitle(this.$itemView); | ||
this.movieList = new MovieList(this.$itemView); | ||
} | ||
|
@@ -35,16 +33,6 @@ class MovieView { | |
this.movieList.hideSkeleton(); | ||
} | ||
|
||
updateMovieListTitle(query) { | ||
if (query) { | ||
this.movieListTitle.changeInnerText(`"${query}" 검색 결과`); | ||
|
||
return; | ||
} | ||
|
||
this.movieListTitle.changeInnerText('지금 인기 있는 영화'); | ||
} | ||
|
||
addMovies({ page, results: movies, total_pages }) { | ||
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. 서버에서 내려오는 |
||
if (page === total_pages) { | ||
// TODO Scroll 이벤트 비활성화 | ||
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. 😢 |
||
|
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.
😭