- Notifications
You must be signed in to change notification settings - Fork849
[과제번역] Part 2. 3.5 Scrolling Tasks#740
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
marco0332 wants to merge1 commit intojavascript-tutorial:masterChoose a base branch frommarco0332:scrollingTasks
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
50 changes: 25 additions & 25 deletions2-ui/3-event-details/8-onscroll/1-endless-page/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
문제 해결의 핵심은 방문자가 문서 끝에 머무르는 동안에 더 많은 날짜들을 페이지에 추가하는 (혹은 실생활 속 물건들을 더 불러오는) 함수입니다. | ||
이 함수를 바로 호출할 수도 있고,`window.onscroll`핸들러로 추가할 수도 있습니다. | ||
여기서 가장 중요한 것은 '페이지 끝까지 스크롤 되었을 때 어떻게 알아챌 것인가?'라는 궁금증입니다. | ||
창-상대 좌표를 이용해보죠. | ||
문서는`<html>`태그, 즉`document.documentElement` 내에 표시됩니다(그리고 포함됩니다). | ||
창-상대 좌표는`document.documentElement.getBoundingClientRect()`로 전체 문서에 대해 얻을 수 있으며,`bottom`프로퍼티는 문서 하단에 대한 창-상대 좌표를 의미하게 됩니다. | ||
예를 들어 전체HTML문서 높이가 `2000px`이라면, | ||
```js | ||
//페이지 상단에 위치할 때 | ||
//창-상대 좌표 top = 0 | ||
document.documentElement.getBoundingClientRect().top = 0 | ||
//창-상대 좌표 bottom = 2000 | ||
//문서가 길기 때문에 아마 하단 영역과 거리가 꽤 멀 것입니다. | ||
document.documentElement.getBoundingClientRect().bottom = 2000 | ||
``` | ||
아래로`500px`만큼 스크롤 한다면, | ||
```js | ||
//문서 상단이 창 500px 위에 위치합니다. | ||
document.documentElement.getBoundingClientRect().top = -500 | ||
//문서 하단과는 500px만큼 가까워집니다. | ||
document.documentElement.getBoundingClientRect().bottom = 1500 | ||
``` | ||
창 높이가 `600px`이라고 가정하고 끝까지 스크롤 할 경우: | ||
```js | ||
//문서 상단이 창 1400px 위에 위치합니다. | ||
document.documentElement.getBoundingClientRect().top = -1400 | ||
//문서 하단이 창 600px 아래에 위치합니다. | ||
document.documentElement.getBoundingClientRect().bottom = 600 | ||
``` | ||
문서`bottom`영역은 창 상단에 도달할 수 없기에`0`이 될 수 없음을 주의해야 합니다.`bottom`좌표 최솟값은 창 높이(600 가정)이며 더 위로 스크롤 할 수 없습니다. | ||
창 높이는`document.documentElement.clientHeight`로 얻을 수 있습니다. | ||
과제를 해결하기 위해 문서 하단이`100px`이하 (높이가 `600`인 경우`600-700px`) 떨어져 있는지 알아야 합니다. | ||
아래 함수를 확인해보세요. | ||
```js | ||
function populate() { | ||
while(true) { | ||
//문서 하단 | ||
let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom; | ||
//유저가 충분히 멀리 스크롤 했을 경우 (끝으로부터100px미만) | ||
if (windowRelativeBottom < document.documentElement.clientHeight + 100) { | ||
//데이터를 추가합니다 | ||
document.body.insertAdjacentHTML("beforeend", `<p>Date: ${new Date()}</p>`); | ||
} | ||
} | ||
} | ||
``` |
16 changes: 8 additions & 8 deletions2-ui/3-event-details/8-onscroll/1-endless-page/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions2-ui/3-event-details/8-onscroll/2-updown-button/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
importance: 5 | ||
— | ||
#위·아래 버튼 | ||
페이지 스크롤을 도와주는 '상단으로' 버튼을 생성합니다. | ||
상단 이동 버튼은 다음과 같이 동작합니다. | ||
-페이지가 최소 창 높이만큼 아래로 스크롤 하지 않았을 경우 - 버튼이 노출되지 않습니다. | ||
-페이지가 창 높이보다 더 아래로 스크롤 될 경우 - '위쪽' 화살표가 좌측 상단 모서리에 표시됩니다. 페이지가 다시 위로 스크롤 된다면 이 화살표는 사라집니다. | ||
-화살표가 클릭 될 경우 페이지는 상단으로 스크롤 됩니다. | ||
아래와 같이 말이죠 (스크롤 해서 좌측 상단 모서리 확인). | ||
[iframe border="1" height="200" link src="solution"] |
18 changes: 9 additions & 9 deletions2-ui/3-event-details/8-onscroll/3-load-visible-img/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions2-ui/3-event-details/8-onscroll/3-load-visible-img/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.