Module PanResponder-BsReactNative
type t;PanResponderreconciles several touches into a single gesture. It makes single-touch gestures resilient to extra touches, and can be used to recognize simple multi-touch gestures.By default, PanResponder holds an
InteractionManagerhandle to block long-running JS events from interrupting active gestures.It provides a predictable wrapper of the responder handlers provided by the gesture responder system. For each handler, it provides a new
gestureStateobject alongside the native event object:onPanResponderMove: [ | `callback(callback(unit)) | `update( list( [ | `X(AnimatedRe.Value.t) | `XY(AnimatedRe.ValueXY.t) | `Y(AnimatedRe.Value.t) ], ), ) ]A native event is a synthetic touch event with the following form:
module NativeEvent: { type t; let changedTouches: t => array(Js.t({..})); let identifier: t => int; let locationX: t => float; let locationY: t => float; let pageX: t => float; let pageY: t => float; let target: t => Js.t({..}); let touches: t => array(Js.t({..})); let timestamp: t => int; let data: t => string; };A gestureState type is the following
type gestureState = { stateID: float, moveX: float, moveY: float, x0: float, y0: float, dx: float, dy: float, vx: float, vy: float, numberActiveTouches: int, };stateID- ID of the gestureState- persisted as long as there at least one touch on screenmoveX- the latest screen coordinates of the recently-moved touchmoveY- the latest screen coordinates of the recently-moved touchx0- the screen coordinates of the responder granty0- the screen coordinates of the responder grantdx- accumulated distance of the gesture since the touch starteddy- accumulated distance of the gesture since the touch startedvx- current velocity of the gesturevy- current velocity of the gesturenumberActiveTouches- Number of touches currently on screen
You can read more on
PanResponderAPI usage in official docs: https://facebook.github.io/react-native/docs/panresponderTypes
t
type t;gestureState
type gestureState = { stateID: float, moveX: float, moveY: float, x0: float, y0: float, dx: float, dy: float, vx: float, vy: float, numberActiveTouches: int, };callback
type callback('a);callback
let callback: ((RNEvent.NativeEvent.t, gestureState) => 'a) => callback('a);create
let create: ( ~onMoveShouldSetPanResponder: callback(bool)=?, ~onMoveShouldSetPanResponderCapture: callback(bool)=?, ~onStartShouldSetPanResponder: callback(bool)=?, ~onStartShouldSetPanResponderCapture: callback(bool)=?, ~onPanResponderReject: callback(unit)=?, ~onPanResponderGrant: callback(unit)=?, ~onPanResponderStart: callback(unit)=?, ~onPanResponderEnd: callback(unit)=?, ~onPanResponderRelease: callback(unit)=?, ~onPanResponderMove: [ | `callback(callback(unit)) | `update( list( [ | `X(AnimatedRe.Value.t) | `XY(AnimatedRe.ValueXY.t) | `Y(AnimatedRe.Value.t) ], ), ) ] =?, ~onPanResponderTerminate: callback(unit)=?, ~onPanResponderTerminationRequest: callback(bool)=?, ~onShouldBlockNativeResponder: callback(bool)=?, unit ) => t;panHandlers
let panHandlers: t => Types.touchResponderHandlers;reference Types.touchResponderHandlers
type touchResponderHandlers = { onMoveShouldSetResponder: option(RNEvent.NativeEvent.t => bool), onMoveShouldSetResponderCapture: option(RNEvent.NativeEvent.t => bool), onResponderGrant: option(RNEvent.NativeEvent.t => unit), onResponderMove: option(RNEvent.NativeEvent.t => unit), onResponderReject: option(RNEvent.NativeEvent.t => unit), onResponderRelease: option(RNEvent.NativeEvent.t => unit), onResponderTerminate: option(RNEvent.NativeEvent.t => unit), onResponderTerminationRequest: option(RNEvent.NativeEvent.t => unit), onStartShouldSetResponder: option(RNEvent.NativeEvent.t => bool), onStartShouldSetResponderCapture: option(RNEvent.NativeEvent.t => bool), };reference RNEvent.NativeEvent
module NativeEvent: { type t; let changedTouches: t => array(Js.t({..})); let identifier: t => int; let locationX: t => float; let locationY: t => float; let pageX: t => float; let pageY: t => float; let target: t => Js.t({..}); let touches: t => array(Js.t({..})); let timestamp: t => int; let data: t => string; };
type gestureState={stateID: float,moveX: float,moveY: float,x0: float,y0: float,dx: float,dy: float,vx: float,vy: float,numberActiveTouches: int,};type callback('a);
let callback: (BsReactNative.RNEvent.NativeEvent.t => gestureState => 'a) => callback('a);let create: ?onMoveShouldSetPanResponder:callback(bool) => ?onMoveShouldSetPanResponderCapture:callback(bool) => ?onStartShouldSetPanResponder:callback(bool) => ?onStartShouldSetPanResponderCapture:callback(bool) => ?onPanResponderReject:callback(unit) => ?onPanResponderGrant:callback(unit) => ?onPanResponderStart:callback(unit) => ?onPanResponderEnd:callback(unit) => ?onPanResponderRelease:callback(unit) => ?onPanResponderMove:[ `callback(callback(unit)) | `update(list([ `X(BsReactNative.AnimatedRe.Value.t) | `XY(BsReactNative.AnimatedRe.ValueXY.t) | `Y(BsReactNative.AnimatedRe.Value.t) ])) ] => ?onPanResponderTerminate:callback(unit) => ?onPanResponderTerminationRequest:callback(bool) => ?onShouldBlockNativeResponder:callback(bool) => unit => t;let panHandlers: t => BsReactNative.Types.touchResponderHandlers;