Skip to content

Commit f3486a9

Browse files
authored
Event.scrollEvent defined for scrollable components (#389)
* Event.scrollEvent defined for scrollable components * fix Event.md
1 parent e02dd5f commit f3486a9

13 files changed

Lines changed: 105 additions & 166 deletions

‎bs-react-native-next/src/apis/Event.bs.js‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,5 @@ function layout(t) {
1313

1414
var NativeLayoutEvent = /* module */[/* layout */layout];
1515

16-
function contentOffset(t) {
17-
var co = t.nativeEvent.contentOffset;
18-
return /* record */[
19-
/* x */co.x,
20-
/* y */co.y
21-
];
22-
}
23-
24-
function contentSize(t) {
25-
var cs = t.nativeEvent.contentSize;
26-
return /* record */[
27-
/* width */cs.width,
28-
/* height */cs.height
29-
];
30-
}
31-
32-
function layoutMeasurement(t) {
33-
var lm = t.nativeEvent.layoutMeasurement;
34-
return /* record */[
35-
/* width */lm.width,
36-
/* height */lm.height
37-
];
38-
}
39-
40-
function contentInset(t) {
41-
var ci = t.nativeEvent.contentInset;
42-
return /* record */[
43-
/* bottom */ci.bottom,
44-
/* top */ci.top,
45-
/* left */ci.left,
46-
/* right */ci.right
47-
];
48-
}
49-
50-
var NativeScrollEvent = /* module */[
51-
/* contentOffset */contentOffset,
52-
/* contentSize */contentSize,
53-
/* layoutMeasurement */layoutMeasurement,
54-
/* contentInset */contentInset
55-
];
56-
5716
exports.NativeLayoutEvent = NativeLayoutEvent;
58-
exports.NativeScrollEvent = NativeScrollEvent;
5917
/* No side effect */

‎bs-react-native-next/src/apis/Event.md‎

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,38 @@ type pressEventPayload = {
2020
"pageY": float,
2121
"target": Js.Nullable.t(float),
2222
"timestamp": float,
23-
"touches": array(pressEventPayload)
23+
"touches": array(pressEventPayload),
2424
};
2525
2626
type pressEvent = event(pressEventPayload);
2727
28+
type position = {
29+
.
30+
"y": float,
31+
"x": float
32+
};
33+
34+
type dimensions = {
35+
.
36+
"height": float,
37+
"width": float
38+
};
39+
40+
type scrollEvent =
41+
event({
42+
.
43+
"contentInset": {
44+
.
45+
"bottom": float,
46+
"left": float,
47+
"right": float,
48+
"top": float
49+
},
50+
"contentOffset": position,
51+
"contentSize": dimensions,
52+
"layoutMeasurement": dimensions
53+
});
54+
2855
type t;
2956
3057
module NativeLayoutEvent = {
@@ -42,43 +69,7 @@ module NativeLayoutEvent = {
4269
};
4370
};
4471
45-
module NativeScrollEvent = {
46-
type t;
47-
type point = {
48-
x: float,
49-
y: float,
50-
};
51-
type size = {
52-
width: float,
53-
height: float,
54-
};
55-
type contentInset = {
56-
bottom: float,
57-
top: float,
58-
left: float,
59-
right: float,
60-
};
61-
[@bs.get] external _nativeEvent: t => Js.t('a) = "nativeEvent";
62-
let contentOffset = (t: t) => {
63-
let co = _nativeEvent(t)##contentOffset;
64-
{x: co##x, y: co##y};
65-
};
66-
let contentSize = (t: t) => {
67-
let cs = _nativeEvent(t)##contentSize;
68-
{width: cs##width, height: cs##height};
69-
};
70-
let layoutMeasurement = (t: t) => {
71-
let lm = _nativeEvent(t)##layoutMeasurement;
72-
{width: lm##width, height: lm##height};
73-
};
74-
let contentInset = (t: t) => {
75-
let ci = _nativeEvent(t)##contentInset;
76-
{bottom: ci##bottom, top: ci##top, left: ci##left, right: ci##right};
77-
};
78-
};
79-
8072
[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent";
8173
82-
[@bs.get] external nativeScrollEvent: t => NativeScrollEvent.t = "nativeEvent";
8374
8475
```

‎bs-react-native-next/src/apis/Event.re‎

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ type pressEventPayload = {
2020

2121
type pressEvent = event(pressEventPayload);
2222

23+
type position = {
24+
.
25+
"y": float,
26+
"x": float,
27+
};
28+
29+
type dimensions = {
30+
.
31+
"height": float,
32+
"width": float,
33+
};
34+
35+
type scrollEvent =
36+
event({
37+
.
38+
"contentInset": {
39+
.
40+
"bottom": float,
41+
"left": float,
42+
"right": float,
43+
"top": float,
44+
},
45+
"contentOffset": position,
46+
"contentSize": dimensions,
47+
"layoutMeasurement": dimensions,
48+
});
49+
2350
type t;
2451

2552
module NativeLayoutEvent = {
@@ -37,41 +64,4 @@ module NativeLayoutEvent = {
3764
};
3865
};
3966

40-
module NativeScrollEvent = {
41-
type t;
42-
type point = {
43-
x: float,
44-
y: float,
45-
};
46-
type size = {
47-
width: float,
48-
height: float,
49-
};
50-
type contentInset = {
51-
bottom: float,
52-
top: float,
53-
left: float,
54-
right: float,
55-
};
56-
[@bs.get] external _nativeEvent: t => Js.t('a) = "nativeEvent";
57-
let contentOffset = (t: t) => {
58-
let co = _nativeEvent(t)##contentOffset;
59-
{x: co##x, y: co##y};
60-
};
61-
let contentSize = (t: t) => {
62-
let cs = _nativeEvent(t)##contentSize;
63-
{width: cs##width, height: cs##height};
64-
};
65-
let layoutMeasurement = (t: t) => {
66-
let lm = _nativeEvent(t)##layoutMeasurement;
67-
{width: lm##width, height: lm##height};
68-
};
69-
let contentInset = (t: t) => {
70-
let ci = _nativeEvent(t)##contentInset;
71-
{bottom: ci##bottom, top: ci##top, left: ci##left, right: ci##right};
72-
};
73-
};
74-
7567
[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent";
76-
77-
[@bs.get] external nativeScrollEvent: t => NativeScrollEvent.t = "nativeEvent";

‎bs-react-native-next/src/components/FlatList.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ external make:
9090
~minimumZoomScale: float=?,
9191
~nestedScrollEnabled: bool=?,
9292
~onContentSizeChange: ((float, float)) => unit=?,
93-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
94-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
95-
~onScroll: Event.NativeScrollEvent.t => unit=?,
96-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
97-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
93+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
94+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
95+
~onScroll: Event.scrollEvent => unit=?,
96+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
97+
~onScrollEndDrag: Event.scrollEvent => unit=?,
9898
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
9999
~pagingEnabled: bool=?,
100100
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/FlatList.re‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ external make:
8383
~minimumZoomScale: float=?,
8484
~nestedScrollEnabled: bool=?,
8585
~onContentSizeChange: ((float, float)) => unit=?,
86-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
87-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
88-
~onScroll: Event.NativeScrollEvent.t => unit=?,
89-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
90-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
86+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
87+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
88+
~onScroll: Event.scrollEvent => unit=?,
89+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
90+
~onScrollEndDrag: Event.scrollEvent => unit=?,
9191
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
9292
~pagingEnabled: bool=?,
9393
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/ScrollView.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ external make:
4141
~minimumZoomScale: float=?,
4242
~nestedScrollEnabled: bool=?,
4343
~onContentSizeChange: ((float, float)) => unit=?,
44-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
45-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
46-
~onScroll: Event.NativeScrollEvent.t => unit=?,
47-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
48-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
44+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
45+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
46+
~onScroll: Event.scrollEvent => unit=?,
47+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
48+
~onScrollEndDrag: Event.scrollEvent => unit=?,
4949
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
5050
~pagingEnabled: bool=?,
5151
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/ScrollView.re‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ external make:
3434
~minimumZoomScale: float=?,
3535
~nestedScrollEnabled: bool=?,
3636
~onContentSizeChange: ((float, float)) => unit=?,
37-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
38-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
39-
~onScroll: Event.NativeScrollEvent.t => unit=?,
40-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
41-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
37+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
38+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
39+
~onScroll: Event.scrollEvent => unit=?,
40+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
41+
~onScrollEndDrag: Event.scrollEvent => unit=?,
4242
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
4343
~pagingEnabled: bool=?,
4444
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/SectionList.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ external make:
9292
~minimumZoomScale: float=?,
9393
~nestedScrollEnabled: bool=?,
9494
~onContentSizeChange: ((float, float)) => unit=?,
95-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
96-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
97-
~onScroll: Event.NativeScrollEvent.t => unit=?,
98-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
99-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
95+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
96+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
97+
~onScroll: Event.scrollEvent => unit=?,
98+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
99+
~onScrollEndDrag: Event.scrollEvent => unit=?,
100100
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
101101
~pagingEnabled: bool=?,
102102
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/SectionList.re‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ external make:
8585
~minimumZoomScale: float=?,
8686
~nestedScrollEnabled: bool=?,
8787
~onContentSizeChange: ((float, float)) => unit=?,
88-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
89-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
90-
~onScroll: Event.NativeScrollEvent.t => unit=?,
91-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
92-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
88+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
89+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
90+
~onScroll: Event.scrollEvent => unit=?,
91+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
92+
~onScrollEndDrag: Event.scrollEvent => unit=?,
9393
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
9494
~pagingEnabled: bool=?,
9595
~refreshControl: React.element=?,

‎bs-react-native-next/src/components/VirtualizedList.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ external make:
144144
~minimumZoomScale: float=?,
145145
~nestedScrollEnabled: bool=?,
146146
~onContentSizeChange: ((float, float)) => unit=?,
147-
~onMomentumScrollBegin: Event.NativeScrollEvent.t => unit=?,
148-
~onMomentumScrollEnd: Event.NativeScrollEvent.t => unit=?,
149-
~onScroll: Event.NativeScrollEvent.t => unit=?,
150-
~onScrollBeginDrag: Event.NativeScrollEvent.t => unit=?,
151-
~onScrollEndDrag: Event.NativeScrollEvent.t => unit=?,
147+
~onMomentumScrollBegin: Event.scrollEvent => unit=?,
148+
~onMomentumScrollEnd: Event.scrollEvent => unit=?,
149+
~onScroll: Event.scrollEvent => unit=?,
150+
~onScrollBeginDrag: Event.scrollEvent => unit=?,
151+
~onScrollEndDrag: Event.scrollEvent => unit=?,
152152
~overScrollMode: [@bs.string] [ | `always | `never | `auto]=?,
153153
~pagingEnabled: bool=?,
154154
~refreshControl: React.element=?,

0 commit comments

Comments
 (0)