forked from TheSpyder/rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebapi__IntersectionObserver.res
61 lines (48 loc) · 1.73 KB
/
Webapi__IntersectionObserver.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Spec: https://www.w3.org/TR/intersection-observer/
*/
module IntersectionObserverEntry = {
/**
* Spec: https://www.w3.org/TR/intersection-observer/#intersection-observer-entry
*/
type t = Dom.intersectionObserverEntry
/* Properties */
@get external time: t => float = "time"
@get external rootBounds: t => Dom.domRect = "rootBounds"
@get external boundingClientRect: t => Dom.domRect = "boundingClientRect"
@get external intersectionRect: t => Dom.domRect = "intersectionRect"
@get external isIntersecting: t => bool = "isIntersecting"
@get external intersectionRatio: t => float = "intersectionRatio"
@get external target: t => Dom.element = "target"
}
type t = Dom.intersectionObserver
type intersectionObserverInit = {
root: option<Dom.element>,
rootMargin: option<string>,
threshold: option<array<float>>, // between 0 and 1.
}
@obj
external makeInit: (
~root: Dom.element=?,
~rootMargin: string=?,
~threshold: array<float>=?,
unit,
) => intersectionObserverInit = ""
@new
external make: (@uncurry (array<IntersectionObserverEntry.t>, t) => unit) => t =
"IntersectionObserver"
@new
external makeWithInit: (
@uncurry (array<IntersectionObserverEntry.t>, t) => unit,
intersectionObserverInit,
) => t = "IntersectionObserver"
/* Properties */
@get @return(nullable)
external root: t => option<Dom.element> = "root"
@get external rootMargin: t => string = "rootMargin"
@get external thresholds: t => array<float> = "thresholds"
/* Methods */
@send external disconnect: t => unit = "disconnect"
@send external observe: (t, Dom.element) => unit = "observe"
@send external unobserve: (t, Dom.element) => unit = "unobserve"
@send external takeRecords: t => array<IntersectionObserverEntry.t> = "takeRecords"