-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadder.js
More file actions
28 lines (23 loc) · 702 Bytes
/
adder.js
File metadata and controls
28 lines (23 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { render } from './render.js'
const addPosts = async (posts, div) => {
for (const post of posts) {
const rendered = await render(post)
div.appendChild(rendered)
}
}
export const adder = (log, src, div) => {
if (log && log[0]) {
let index = 0
const reverse = log.slice().reverse()
let posts = reverse.slice(index, index + 25)
addPosts(posts, div)
index = index + 25
window.onscroll = () => {
if (((window.innerHeight + window.scrollY) >= document.body.scrollHeight - 1000) && window.location.hash.substring(1) === src) {
posts = reverse.slice(index, index + 25)
index = index + 25
addPosts(posts, div)
}
}
}
}