Skip to content

Commit 2e352b4

Browse files
committed
Support native driver.
1 parent 9e89cf0 commit 2e352b4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

GestureHandler.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,26 @@ function createHandler(handlerName, propTypes = null, config = {}) {
116116
}
117117

118118
render() {
119+
let gestureEventHandler = this._onGestureHandlerEvent;
120+
const { onGestureEvent, onGestureHandlerEvent } = this.props;
121+
if (onGestureEvent && (typeof onGestureEvent !== 'function')) {
122+
// If it's not a mathod it should be an native Animated.event
123+
// object. We set it directly as the handler for the view
124+
// In this case nested handlers are not going to be supported
125+
if (onGestureHandlerEvent) {
126+
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
127+
}
128+
gestureEventHandler = this.props.onGestureEvent;
129+
} else {
130+
if (onGestureHandlerEvent && (typeof onGestureHandlerEvent !== 'function')) {
131+
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
132+
}
133+
}
119134
const child = React.Children.only(this.props.children);
120135
return React.cloneElement(child, {
121136
ref: CHILD_REF,
122137
collapsable: false,
123-
onGestureHandlerEvent: this._onGestureHandlerEvent,
138+
onGestureHandlerEvent: gestureEventHandler,
124139
onGestureHandlerStateChange: this._onGestureHandlerStateChange,
125140
});
126141
}

0 commit comments

Comments
 (0)