cordova-plugin-camera-preview icon indicating copy to clipboard operation
cordova-plugin-camera-preview copied to clipboard

setting the x and y position after camera start

Open cpgb85 opened this issue 7 years ago • 3 comments

Is there any method to set the x and y position of the preview after the cam has already started? I need to deal with device orientation.

cpgb85 avatar Jun 05 '18 19:06 cpgb85

I have a similar need, since I want the preview to follow where the user scrolls the page view in my app.

I might have an idea on how this could be fixed for iOS:

In CameraPreview.m, startCamera sets the x and y position (Link to source)

self.cameraRenderController.view.frame = CGRectMake(x, y, width, height);

In CameraPreview.m, setPreviewSize, the x and y position are set to 0,0. But we could easily give x,y parameters here (Link to source)

 self.cameraRenderController.view.frame = CGRectMake(0, 0, width, height); 

@westonganger Do you have ideas on the best way to make this change in the API?

  1. create a new method, setPreviewPosition, which would pass the appropriate x,y positions?
  2. create a new method, setPreviewRect, which x,y,width,height could all be set in one call?

I might be willing to submit a PR for this functionality

youralien avatar Jul 20 '18 16:07 youralien

@youralien setPreviewPosition() would be ideal

because when user scrolls, you only need to set x & y axis when window resize only then you'll call the resize function

NicksonYap avatar Feb 11 '19 07:02 NicksonYap

There seems to a be related issue but I don't understand https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/issues/145

NicksonYap avatar Feb 11 '19 07:02 NicksonYap