cordova-plugin-camera-preview / cordova-plugin-camera-preview

Cordova plugin that allows camera interaction from HTML code
MIT License
570 stars 560 forks source link

Camera Preview position #400

Open richardgazdik opened 6 years ago

richardgazdik commented 6 years ago

Is there a way to set the XY coords of the camera preview after initialisation? Although I can set the size of the preview window, positioning on runtime is still a missing feature.

saurabhindoria commented 6 years ago

Yes, the options which you pass in the startCamera function actually defines the x and y coords.

var options = {x: 10, y: 10, width: 300, height: 300, toBack: flase, previewDrag: true, tapPhoto: true};
CameraPreview.startCamera(options);

The above options would mean the top left corner of the preview will be at x=10 and y=10 with the size of the preview as 300x300.

richardgazdik commented 6 years ago

Can I bind the startCamera function to a scroll event? (I'd like to change the preview's position in parallel with the view's scrollTop parameter).

Zolomon commented 6 years ago

This is exactly what I have been trying to achieve.

I would like to refactor setPreviewSize and extend it to also take { x: number, y: number} so that you can move the preview viewport.

Zolomon commented 6 years ago

According to https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/blob/master/src/ios/CameraPreview.m#L19-L23 it looks like you cannot restart the camera without stopping it first, which is not very good for user interaction.

Zolomon commented 6 years ago

I see that if we modify these lines https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/blob/master/src/ios/CameraPreview.m#L523-L526 to also include x and y coordinates and feed them into CGRectMake(x, y, width, height) then we should accomplish what we want.

yuricamara commented 5 years ago

Any updates?