Skip to content

Commit 1bd9b9e

Browse files
authored
Merge pull request #2054 from peachesontour/patch-7
The solution here had no break, an infinite loop. Modified to match plunker example code
2 parents ba6ae24 + 8a70b74 commit 1bd9b9e

File tree

1 file changed

+5
-5
lines changed
  • 2-ui/3-event-details/8-onscroll/1-endless-page

1 file changed

+5
-5
lines changed

2-ui/3-event-details/8-onscroll/1-endless-page/solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ function populate() {
5555
// document bottom
5656
let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom;
5757

58-
// if the user scrolled far enough (<100px to the end)
59-
if (windowRelativeBottom < document.documentElement.clientHeight + 100) {
60-
// let's add more data
61-
document.body.insertAdjacentHTML("beforeend", `<p>Date: ${new Date()}</p>`);
62-
}
58+
// if the user hasn't scrolled far enough (>100px to the end)
59+
if (windowRelativeBottom > document.documentElement.clientHeight + 100) break;
60+
61+
// let's add more data
62+
document.body.insertAdjacentHTML("beforeend", `<p>Date: ${new Date()}</p>`);
6363
}
6464
}
6565
```

0 commit comments

Comments
 (0)