@@ -18,6 +18,7 @@ module Animation = {
1818
1919module type Value = {
2020 type t;
21+ type jsValue;
2122 type rawJsType;
2223};
2324
@@ -27,8 +28,6 @@ type regular;
2728
2829type value('a);
2930
30- type valueXY;
31-
3231module ValueAnimations = (Val: Value) => {
3332 module Decay = {
3433 type config;
@@ -155,14 +154,15 @@ module ValueOperations = {
155154 let interpolate = Interpolation.interpolate;
156155};
157156
158- module Value = {
159- type t = value(regular);
160- type jsValue = {. "value": float};
157+ module ValueMethods = (Val: Value) => {
158+ type t = Val.t;
159+ type jsValue = Val.jsValue;
160+ type rawJsType = Val.rawJsType;
161+
161162 type callback = jsValue => unit;
162- [@bs.new] [@bs.scope "Animated"] [@bs.module "react-native"]
163- external create: float => t = "Value";
164- [@bs.send] external setValue: (t, float) => unit = "";
165- [@bs.send] external setOffset: (t, float) => unit = "";
163+
164+ [@bs.send] external setValue: (t, rawJsType) => unit = "";
165+ [@bs.send] external setOffset: (t, rawJsType) => unit = "";
166166 [@bs.send] external flattenOffset: t => unit = "";
167167 [@bs.send] external extractOffset: t => unit = "";
168168 [@bs.send] external addListener: (t, callback) => string = "";
@@ -175,21 +175,37 @@ module Value = {
175175 [@bs.send]
176176 external stopAnimation: (t, ~callback: callback=?, unit) => unit = "";
177177
178- include ValueAnimations({
178+ include ValueAnimations(Val);
179+ };
180+
181+ module Value = {
182+ include ValueMethods({
179183 type t = value(regular);
184+ type jsValue = {. "value": float};
180185 type rawJsType = float;
181186 });
187+
188+ [@bs.new] [@bs.scope "Animated"] [@bs.module "react-native"]
189+ external create: float => t = "Value";
190+
182191 include ValueOperations;
183192};
184193
185194module ValueXY = {
186- type t = valueXY;
187- type jsValue = {
188- .
189- "x": float,
190- "y": float,
191- };
192- type callback = jsValue => unit;
195+ include ValueMethods({
196+ type t = {
197+ .
198+ "x": Value.t,
199+ "y": Value.t,
200+ };
201+ type jsValue = {
202+ .
203+ "x": float,
204+ "y": float,
205+ };
206+ type rawJsType = jsValue;
207+ });
208+
193209 type translateTransform = {
194210 .
195211 "translateX": Value.t,
@@ -202,27 +218,8 @@ module ValueXY = {
202218 };
203219 [@bs.new] [@bs.scope "Animated"] [@bs.module "react-native"]
204220 external create: jsValue => t = "ValueXY";
205-
206- [@bs.send] external setValue: (t, jsValue) => unit = "";
207- [@bs.send] external setOffset: (t, jsValue) => unit = "";
208- [@bs.send] external flattenOffset: t => unit = "";
209- [@bs.send] external extractOffset: t => unit = "";
210- [@bs.send]
211- external resetAnimation: (t, ~callback: callback=?, unit) => unit = "";
212-
213- [@bs.send]
214- external stopAnimation: (t, ~callback: callback=?, unit) => unit = "";
215- [@bs.send] external addListener: (t, callback) => string = "";
216- [@bs.send] external removeListener: (t, string) => unit = "";
217- [@bs.send] external removeAllListeners: t => unit = "";
218221 [@bs.send] external getLayout: t => layout = "";
219222 [@bs.send] external getTranslateTransform: t => translateTransform = "";
220- [@bs.get] external getX: t => Value.t = "x";
221- [@bs.get] external getY: t => Value.t = "y";
222- include ValueAnimations({
223- type t = valueXY;
224- type rawJsType = jsValue;
225- });
226223};
227224
228225[@bs.module "react-native"] [@bs.scope "Animated"]
0 commit comments