Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ To have Play Services [pre-download the model in the background after the app is
| `zoom` | `number` | Control the zoom. Default: `1.0` |
| `maxZoom` | `number` | Maximum zoom allowed (but not beyond what camera allows). Default: `undefined` (camera default max) |
| `onZoom` | Function | Callback when user makes a pinch gesture, regardless of what the `zoom` prop was set to. Returned event contains `zoom`. Ex: `onZoom={(e) => console.log(e.nativeEvent.zoom)}`. |
| `onTapToFocus` | Function | Callback when the user taps the preview to focus, fired alongside the built-in tap-to-focus so an overlay can be shown without suppressing focus and zoom. Returned event contains `x` and `y`, normalized 0-1 in preview space. Requires `focusMode` `'on'`. Ex: `onTapToFocus={(e) => console.log(e.nativeEvent.x, e.nativeEvent.y)}`. |
| `onTapToFocus` | Function | Callback when the user taps the preview to focus, fired alongside the built-in tap-to-focus so an overlay can be shown without suppressing focus and zoom. Returned event contains `x` and `y`, normalized 0-1 in preview space. On iOS, requires `focusMode` `'on'`. Ex: `onTapToFocus={(e) => console.log(e.nativeEvent.x, e.nativeEvent.y)}`. |
| `torchMode` | `'on'`/`'off'` | Toggle flash light when camera is active. Default: `off` |
| `cameraType` | CameraType.Back/CameraType.Front | Choose what camera to use. Default: `CameraType.Back` |
| `onOrientationChange` | Function | Callback when physical device orientation changes. Returned event contains `orientation`. Ex: `onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}`. Use `import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... }` to understand the new value |
Expand Down
10 changes: 9 additions & 1 deletion android/src/main/java/com/rncamerakit/CKCamera.kt
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,20 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs
})

// Tap to focus
var isMultiTouchGesture = false
viewFinder.setOnTouchListener { _, event ->
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
isMultiTouchGesture = false
} else if (event.pointerCount > 1) {
isMultiTouchGesture = true
}
if (event.action != MotionEvent.ACTION_UP) {
return@setOnTouchListener scaleDetector.onTouchEvent(event)
}
focusOnPoint(event.x, event.y)
onTapToFocus(event.x, event.y)
if (!isMultiTouchGesture) {
onTapToFocus(event.x, event.y)
}
return@setOnTouchListener true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class TapToFocusEvent(
) : Event<TapToFocusEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

override fun canCoalesce(): Boolean = false

override fun getEventData(): WritableMap =
Arguments.createMap().apply {
putDouble("x", x)
Expand Down
2 changes: 1 addition & 1 deletion src/CameraProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface CameraProps extends ViewProps {
* without replacing the camera's own gesture handling.
*
* Coordinates are normalized 0-1 in preview space, matching `onFaceDetected`.
* Requires `focusMode="on"` (the default), since that is when the
* On iOS, requires `focusMode="on"` (the default), since that is when the
* tap-to-focus gesture is active.
*
* Note this is deliberately not called `onFocus`: `ViewProps` already
Expand Down