Event
Official documentation These are the types of objects returned in Event
callbacks. Types are instances of syntheticEvent('a)
and responderSyntheticEvent('a)
.
type syntheticEvent('a) = {
.
"bubbles": Js.Nullable.t(bool),
"cancelable": Js.Nullable.t(bool),
"currentTarget": float,
"defaultPrevented": Js.Nullable.t(bool),
"dispatchConfig": {. "registrationName": string},
"eventPhase": Js.Nullable.t(float),
[@bs.meth] "preventDefault": unit => unit,
[@bs.meth] "isDefaultPrevented": unit => bool,
[@bs.meth] "stopPropagation": unit => unit,
[@bs.meth] "isPropagationStopped": unit => bool,
"isTrusted": Js.Nullable.t(bool),
"nativeEvent": 'a,
[@bs.meth] "persist": unit => unit,
"target": Js.Nullable.t(float),
"timeStamp": float,
"_type": Js.Nullable.t(string),
};
responderSyntheticEvent('a)
adds the touchHistory
key to syntheticEvent('a)
type responderSyntheticEvent('a) = {
.
// synthethicEvent keys
"bubbles": Js.Nullable.t(bool),
"cancelable": Js.Nullable.t(bool),
"currentTarget": float,
"defaultPrevented": Js.Nullable.t(bool),
"dispatchConfig": {. "registrationName": string},
"eventPhase": Js.Nullable.t(float),
[@bs.meth] "preventDefault": unit => unit,
[@bs.meth] "isDefaultPrevented": unit => bool,
[@bs.meth] "stopPropagation": unit => unit,
[@bs.meth] "isPropagationStopped": unit => bool,
"isTrusted": Js.Nullable.t(bool),
"nativeEvent": 'a,
[@bs.meth] "persist": unit => unit,
"target": Js.Nullable.t(float),
"timeStamp": float,
"_type": Js.Nullable.t(string),
"touchHistory": {
.
"indexOfSingleActiveTouch": float,
"mostRecentTimeStamp": float,
"numberActiveTouches": float,
"touchBank":
array({
.
"touchActive": bool,
"startPageX": float,
"startPageY": float,
"startTimeStamp": float,
"currentPageX": float,
"currentPageY": float,
"currentTimeStamp": float,
"previousPageX": float,
"previousPageY": float,
"previousTimeStamp": float,
}),
},
};
type layoutEvent = syntheticEvent(layout)
where layout
is defined as
type layout = {
x: float,
y: float,
width: float,
height: float,
};
type pressEvent = responderSyntheticEvent(pressEventPayload);
where pressEventPayload
is defined as
type pressEventPayload = {
changedTouches: array(pressEventPayload),
force: float,
identifier: int,
locationX: float,
locationY: float,
pageX: float,
pageY: float,
target: Js.Nullable.t(float),
timestamp: float,
touches: array(pressEventPayload),
};
type scrollEvent = syntheticEvent(scrollEventPayload)
where scrollEventPayload
is defined as
type scrollEventPayload = {
contentInset,
contentOffset,
contentSize: dimensions,
layoutMeasurement: dimensions,
}
and contentInset
, contentOffset
and dimensions
are defined as
type contentInset = {
bottom: float,
left: float,
right: float,
top: float,
};
type contentOffset = {
x: float,
y: float,
};
type dimensions = {
height: float,
width: float,
};
type switchChangeEvent = syntheticEvent(switchChangePayload)
where switchChangePayload
is defined as
type switchChangePayload = {value: bool};
type targetEvent = syntheticEvent(targetPayload)
where targetPayload
is defined as
type targetPayload = {target: int};
type textLayoutEvent = syntheticEvent(textLayouts);
where textLayouts
and textLayout
are defined as
type textLayouts = {lines: array(textLayout)};
and
type textLayout = {
x: float,
y: float,
width: float,
height: float,
ascender: float, // verify
capHeight: float, // verify
descender: float, // verify
text: string,
xHeight: float // verify
};