Skip to content

Commit e78d5ed

Browse files
authored
Merge pull request #2001 from numbersprotocol/feat-tap-to-focus
Feat tap to focus
2 parents dbf9494 + b94188e commit e78d5ed

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

package-lock.json

Lines changed: 28 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/features/home/custom-camera/custom-camera.page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*transloco="let t"
55
>
66
<ng-container *ngIf="(mode$ | ngrxPush) === 'capture'">
7-
<div id="camera-flash-placeholder"></div>
7+
<div id="camera-flash-placeholder" (click)="focus($event)"></div>
88

99
<mat-icon
1010
*ngIf="isFlashAvailable"

src/app/features/home/custom-camera/custom-camera.page.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ export class CustomCameraPage implements OnInit, OnDestroy {
187187
this.isFlashOn = (await this.customCameraService.isTorchOn()).result;
188188
}
189189

190+
// eslint-disable-next-line class-methods-use-this
191+
async focus(event: PointerEvent | MouseEvent) {
192+
await this.customCameraService.focus(event.x, event.y);
193+
}
194+
190195
async leaveCustomCamera() {
191196
return this.location.back();
192197
}

src/app/features/home/custom-camera/custom-camera.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ export class CustomCameraService {
115115
return Promise.resolve();
116116
}
117117

118+
async focus(x: number, y: number) {
119+
if (this.isNativePlatform) {
120+
return await PreviewCamera.focus({ x, y });
121+
}
122+
return Promise.resolve();
123+
}
124+
118125
async isTorchAvailable(): Promise<boolean> {
119126
if (this.isNativePlatform) {
120127
return (await PreviewCamera.isTorchAvailable()).result;

0 commit comments

Comments
 (0)