1 module libwasm.bindings.IntersectionObserver;
2 
3 import libwasm.types;
4 
5 import memutils.ct: tuple;
6 import libwasm.bindings.DOMRect;
7 import libwasm.bindings.Element;
8 import libwasm.bindings.Performance;
9 
10 @safe:
11 nothrow:
12 
13 alias IntersectionCallback = void delegate(Sequence!(IntersectionObserverEntry), IntersectionObserver);
14 struct IntersectionObserver {
15   nothrow:
16   JsHandle handle;
17   alias handle this;
18   this(Handle h) {
19     this.handle = JsHandle(h);
20   }
21   auto root()() {
22     return recastOpt!(Element)(Object_Getter__OptionalHandle(this.handle, "root"));
23   }
24   string rootMargin()() {
25     return Object_Getter__string(this.handle, "rootMargin");
26   }
27   auto thresholds()() {
28     return Sequence!(double)(Object_Getter__Handle(this.handle, "thresholds"));
29   }
30   void observe()(scope ref Element target) {
31     Object_Call_Handle__void(this.handle, "observe", target._parent);
32   }
33   void unobserve()(scope ref Element target) {
34     Object_Call_Handle__void(this.handle, "unobserve", target._parent);
35   }
36   void disconnect()() {
37     Object_Call__void(this.handle, "disconnect");
38   }
39   auto takeRecords()() {
40     return Sequence!(IntersectionObserverEntry)(Object_Getter__Handle(this.handle, "takeRecords"));
41   }
42   IntersectionCallback intersectionCallback()() {
43     return IntersectionObserver_intersectionCallback_Get(this.handle);
44   }
45 }
46 struct IntersectionObserverEntry {
47   nothrow:
48   JsHandle handle;
49   alias handle this;
50   this(Handle h) {
51     this.handle = JsHandle(h);
52   }
53   double time()() {
54     return Object_Getter__double(this.handle, "time");
55   }
56   auto rootBounds()() {
57     return recastOpt!(DOMRectReadOnly)(Object_Getter__OptionalHandle(this.handle, "rootBounds"));
58   }
59   auto boundingClientRect()() {
60     return DOMRectReadOnly(Object_Getter__Handle(this.handle, "boundingClientRect"));
61   }
62   auto intersectionRect()() {
63     return DOMRectReadOnly(Object_Getter__Handle(this.handle, "intersectionRect"));
64   }
65   bool isIntersecting()() {
66     return Object_Getter__bool(this.handle, "isIntersecting");
67   }
68   double intersectionRatio()() {
69     return Object_Getter__double(this.handle, "intersectionRatio");
70   }
71   auto target()() {
72     return Element(Object_Getter__Handle(this.handle, "target"));
73   }
74 }
75 struct IntersectionObserverEntryInit {
76   nothrow:
77   JsHandle handle;
78   alias handle this;
79   this(Handle h) {
80     this.handle = JsHandle(h);
81   }
82   static auto create() {
83     return IntersectionObserverEntryInit(libwasm_add__object());
84   }
85   void time()(double time) {
86     Object_Call_double__void(this.handle, "time", time);
87   }
88   double time()() {
89     return Object_Getter__double(this.handle, "time");
90   }
91   void rootBounds()(scope ref DOMRectInit rootBounds) {
92     Object_Call_Handle__void(this.handle, "rootBounds", rootBounds.handle);
93   }
94   auto rootBounds()() {
95     return DOMRectInit(Object_Getter__Handle(this.handle, "rootBounds"));
96   }
97   void boundingClientRect()(scope ref DOMRectInit boundingClientRect) {
98     Object_Call_Handle__void(this.handle, "boundingClientRect", boundingClientRect.handle);
99   }
100   auto boundingClientRect()() {
101     return DOMRectInit(Object_Getter__Handle(this.handle, "boundingClientRect"));
102   }
103   void intersectionRect()(scope ref DOMRectInit intersectionRect) {
104     Object_Call_Handle__void(this.handle, "intersectionRect", intersectionRect.handle);
105   }
106   auto intersectionRect()() {
107     return DOMRectInit(Object_Getter__Handle(this.handle, "intersectionRect"));
108   }
109   void target()(scope ref Element target) {
110     Object_Call_Handle__void(this.handle, "target", target.handle);
111   }
112   auto target()() {
113     return Element(Object_Getter__Handle(this.handle, "target"));
114   }
115 }
116 struct IntersectionObserverInit {
117   nothrow:
118   JsHandle handle;
119   alias handle this;
120   this(Handle h) {
121     this.handle = JsHandle(h);
122   }
123   static auto create() {
124     return IntersectionObserverInit(libwasm_add__object());
125   }
126   void root(T0)(scope auto ref Optional!(T0) root) if (isTOrPointer!(T0, Element)) {
127     Serialize_Object_VarArgCall!void(this.handle, "root", "Optional!Handle", tuple(!root.empty, cast(Handle)root.front._parent));
128   }
129   auto root()() {
130     return recastOpt!(Element)(Object_Getter__OptionalHandle(this.handle, "root"));
131   }
132   void rootMargin()(string rootMargin) {
133     Object_Call_string__void(this.handle, "rootMargin", rootMargin);
134   }
135   string rootMargin()() {
136     return Object_Getter__string(this.handle, "rootMargin");
137   }
138   void threshold()(scope ref SumType!(double, Sequence!(double)) threshold) {
139     Serialize_Object_VarArgCall!void(this.handle, "threshold", "SumType!(double,Handle)", tuple(libwasm.sumtype.match!(((double v) => 0),((ref threshold.Types[1] v) => 1))(threshold),tuple(libwasm.sumtype.match!(((double v) => v),((ref threshold.Types[1] v) => double.init))(threshold),libwasm.sumtype.match!(((double v) => Handle.init),((ref threshold.Types[1] v) => cast(Handle)v.handle))(threshold))));
140   }
141   auto threshold()() {
142     return Object_Getter__Handle(this.handle, "threshold");
143   }
144 }
145 
146 
147 extern (C) IntersectionCallback IntersectionObserver_intersectionCallback_Get(Handle);