aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/document_watcher.coffee
blob: 11cf7d535a12957f36c851c03eb0e4335dbe267d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# emit key once half the viewport is covered

isReady = ->
  if not (document?.body?)
    return false
  return document.body.scrollHeight > innerHeight + 100

if isReady()
  console.log("Already ready")
  Frost?.isReady()
  return

console.log("Injected document watcher")

observer = new MutationObserver(() ->
  if isReady()
    observer.disconnect()
    Frost?.isReady()
    console.log("Documented surpassed height in #{performance.now()}")
)

observer.observe document,
  childList: true
  subtree: true