forked from TheSpyder/rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebapi__IntersectionObserver__test.js
More file actions
49 lines (34 loc) · 1.29 KB
/
Copy pathWebapi__IntersectionObserver__test.js
File metadata and controls
49 lines (34 loc) · 1.29 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
var Belt_Option = require("rescript/lib/js/belt_Option.js");
var Caml_option = require("rescript/lib/js/caml_option.js");
var TestHelpers = require("../testHelpers.js");
var Webapi__Dom__Document = require("../../src/Webapi/Dom/Webapi__Dom__Document.js");
var el = document.createElement("div");
var body = TestHelpers.unsafelyUnwrapOption(Belt_Option.flatMap(Webapi__Dom__Document.asHtmlDocument(document), (function (prim) {
return Caml_option.nullable_to_opt(prim.body);
})));
el.innerText = "Hello There";
el.setAttribute("style", "margin-top: 800px; margin-bottom: 800px");
el.appendChild(body);
function handler(entries, observer) {
entries.forEach(function (entry) {
console.log(entry.time);
console.log(entry.rootBounds);
console.log(entry.boundingClientRect);
console.log(entry.intersectionRect);
console.log(entry.isIntersecting);
console.log(entry.intersectionRatio);
console.log(entry.target);
});
observer.unobserve(el);
}
var observer = new IntersectionObserver(handler);
observer.observe(el);
observer.unobserve(el);
observer.observe(el);
observer.disconnect();
exports.el = el;
exports.body = body;
exports.handler = handler;
exports.observer = observer;
/* el Not a pure module */