@capgo/camera-preview 7.8.1 → 7.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -386,6 +386,12 @@ extension CameraController {
386
386
  // Update internal state
387
387
  self.requestedAspectRatio = aspectRatio
388
388
 
389
+ // Preserve current zoom level before session reconfiguration
390
+ var currentZoom: CGFloat?
391
+ if let device = (currentCameraPosition == .rear) ? rearCamera : frontCamera {
392
+ currentZoom = device.videoZoomFactor
393
+ }
394
+
389
395
  // Reconfigure session preset to match the new ratio for optimal capture resolution
390
396
  if let captureSession = self.captureSession {
391
397
  captureSession.beginConfiguration()
@@ -393,6 +399,19 @@ extension CameraController {
393
399
  captureSession.commitConfiguration()
394
400
  }
395
401
 
402
+ // Restore zoom level after session reconfiguration
403
+ if let zoom = currentZoom, let device = (currentCameraPosition == .rear) ? rearCamera : frontCamera {
404
+ do {
405
+ try device.lockForConfiguration()
406
+ device.videoZoomFactor = zoom
407
+ device.unlockForConfiguration()
408
+ self.zoomFactor = zoom
409
+ print("[CameraPreview] Preserved zoom level \(zoom) after aspect ratio change")
410
+ } catch {
411
+ print("[CameraPreview] Failed to restore zoom level after aspect ratio change: \(error)")
412
+ }
413
+ }
414
+
396
415
  // Update preview layer geometry on the main thread
397
416
  DispatchQueue.main.async { [weak self] in
398
417
  guard let self = self, let previewLayer = self.previewLayer else { return }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "7.8.1",
3
+ "version": "7.8.2",
4
4
  "description": "Camera preview",
5
5
  "license": "MIT",
6
6
  "repository": {