From c5a01cb9d71ba5b97295381084293a28a5d49df1 Mon Sep 17 00:00:00 2001 From: "Igor M." Date: Tue, 13 Aug 2024 21:37:39 +0300 Subject: [PATCH 1/3] =?UTF-8?q?Fix=20endless=20loop=20in=20description=20t?= =?UTF-8?q?o=20solution=20of=201st=20task=20"=D0=91=D0=B5=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D1=87=D0=BD=D0=B0=D1=8F=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=86=D0=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code in description to solution of 1st task "Бесконечная страница" causes page "freeze" due the endless loop "while" - fix that with "while" loop with "break" inside. --- .../8-onscroll/1-endless-page/solution.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md index 14646284ee..0281fe06e9 100644 --- a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md +++ b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md @@ -55,11 +55,13 @@ function populate() { // нижняя граница документа let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom; - // если пользователь прокрутил достаточно далеко (< 100px до конца) - if (windowRelativeBottom < document.documentElement.clientHeight + 100) { - // добавим больше данных - document.body.insertAdjacentHTML("beforeend", `

Дата: ${new Date()}

`); + // если до конца страницы достаточно далеко (> 100px до конца) - прерываем цикл; + if (windowRelativeBottom > document.documentElement.clientHeight + 100) { + break; } + + // добавим больше данных + document.body.insertAdjacentHTML("beforeend", `

Date: ${new Date()}

`); } } ``` From da357c60fdc4997804ead14eccb2b0af757b4b91 Mon Sep 17 00:00:00 2001 From: Aleksandras Date: Wed, 14 Aug 2024 13:41:25 +0300 Subject: [PATCH 2/3] minor --- 2-ui/3-event-details/8-onscroll/1-endless-page/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md index 0281fe06e9..c058bece01 100644 --- a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md +++ b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md @@ -55,7 +55,7 @@ function populate() { // нижняя граница документа let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom; - // если до конца страницы достаточно далеко (> 100px до конца) - прерываем цикл; + // если до конца страницы достаточно далеко (>100px до конца) - прерываем цикл; if (windowRelativeBottom > document.documentElement.clientHeight + 100) { break; } From f41384363a70c4adb9e1240ff8ba6b23b48a9352 Mon Sep 17 00:00:00 2001 From: Aleksandras Date: Wed, 14 Aug 2024 13:43:37 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D1=81=D1=82=D0=B8=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2-ui/3-event-details/8-onscroll/1-endless-page/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md index c058bece01..b58a18e06f 100644 --- a/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md +++ b/2-ui/3-event-details/8-onscroll/1-endless-page/solution.md @@ -55,7 +55,7 @@ function populate() { // нижняя граница документа let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom; - // если до конца страницы достаточно далеко (>100px до конца) - прерываем цикл; + // если пользователь не прокрутил достаточно далеко (>100px до конца страницы) — прерываем цикл if (windowRelativeBottom > document.documentElement.clientHeight + 100) { break; }