forked from TheSpyder/rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebapi__IntersectionObserver__test.res
31 lines (25 loc) · 1.39 KB
/
Webapi__IntersectionObserver__test.res
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
29
30
31
let el = Webapi.Dom.document -> Webapi.Dom.Document.createElement("div")
let body =
Webapi.Dom.Document.asHtmlDocument(Webapi.Dom.document)
->Belt.Option.flatMap(Webapi.Dom.HtmlDocument.body)
->TestHelpers.unsafelyUnwrapOption
Webapi.Dom.Element.setInnerText(el, "Hello There")
Webapi.Dom.Element.setAttribute(el, "style", "margin-top: 800px; margin-bottom: 800px")
Webapi.Dom.Element.appendChild(body, el)
let handler = (entries, observer) => {
Js.Array.forEach(entry => {
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.time(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.rootBounds(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.boundingClientRect(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.intersectionRect(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.isIntersecting(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.intersectionRatio(entry))
Js.log(Webapi.IntersectionObserver.IntersectionObserverEntry.target(entry))
}, entries)
Webapi.IntersectionObserver.unobserve(observer, el)
}
let observer = Webapi.IntersectionObserver.make(handler)
Webapi.IntersectionObserver.observe(observer, el)
Webapi.IntersectionObserver.unobserve(observer, el)
Webapi.IntersectionObserver.observe(observer, el)
Webapi.IntersectionObserver.disconnect(observer)