I am using expo camera and I have wrapped it inside TapGestureHandler
so I can detect tap event. Here is the code:
<TapGestureHandler onHandlerStateChange={onSingleTapEvent}>
<View>
<Camera
ref={cameraRef}
type={cameraType}
ratio={ratio}
onCameraReady={onCameraReady}
autoFocus={Camera.Constants.AutoFocus.on}
></Camera>
</View>
</TapGestureHandler>;
My onSingleTapEvent
:
const onSingleTapEvent = (event) => {
if (event.nativeEvent.state === State.ACTIVE) {
console.log("Single tap event: ", event.nativeEvent);
}
};
When I tap on the screen I see the following console output:
Single tap event: Object {
"absoluteX": 210.3333282470703,
"absoluteY": 527.3333129882812,
"handlerTag": 3,
"numberOfPointers": 1,
"oldState": 2,
"state": 4,
"x": 210.3333282470703,
"y": 446.3333435058594,
}
My question is, how do I implement tap on focus? As far as I understand I need to play with focusDepth
property of expo camera, but I don't know how to set it? Any ideas, bogs or pseudo code would be grant!
I've found a nice way to do this by resetting the autofocus on user tap event and it works really well.