@capgo/camera-preview 7.6.0 → 7.6.1-alpha.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.
@@ -72,31 +72,6 @@ class CameraController: NSObject {
72
72
  // Track whether an aspect ratio was explicitly requested
73
73
  var requestedAspectRatio: String?
74
74
 
75
- private func calculateAspectRatioFrame(for aspectRatio: String, in bounds: CGRect) -> CGRect {
76
- guard let ratio = parseAspectRatio(aspectRatio) else {
77
- return bounds
78
- }
79
-
80
- let targetAspectRatio = ratio.width / ratio.height
81
- let viewAspectRatio = bounds.width / bounds.height
82
-
83
- var frame: CGRect
84
-
85
- if viewAspectRatio > targetAspectRatio {
86
- // View is wider than target - fit by height
87
- let targetWidth = bounds.height * targetAspectRatio
88
- let xOffset = (bounds.width - targetWidth) / 2
89
- frame = CGRect(x: xOffset, y: 0, width: targetWidth, height: bounds.height)
90
- } else {
91
- // View is taller than target - fit by width
92
- let targetHeight = bounds.width / targetAspectRatio
93
- let yOffset = (bounds.height - targetHeight) / 2
94
- frame = CGRect(x: 0, y: yOffset, width: bounds.width, height: targetHeight)
95
- }
96
-
97
- return frame
98
- }
99
-
100
75
  private func parseAspectRatio(_ aspectRatio: String) -> (width: CGFloat, height: CGFloat)? {
101
76
  let components = aspectRatio.split(separator: ":").compactMap { Float(String($0)) }
102
77
  guard components.count == 2 else { return nil }
@@ -454,12 +429,9 @@ extension CameraController {
454
429
  // Configure video gravity and frame based on aspect ratio
455
430
  if let aspectRatio = requestedAspectRatio {
456
431
  // Calculate the frame based on requested aspect ratio
457
- let frame = calculateAspectRatioFrame(for: aspectRatio, in: view.bounds)
458
- previewLayer.frame = frame
459
432
  previewLayer.videoGravity = .resizeAspectFill
460
433
  } else {
461
434
  // No specific aspect ratio requested - fill the entire view
462
- previewLayer.frame = view.bounds
463
435
  previewLayer.videoGravity = .resizeAspect
464
436
  }
465
437
 
@@ -530,7 +502,7 @@ extension CameraController {
530
502
  }
531
503
 
532
504
  private func updateVideoOrientationOnMainThread() {
533
- let videoOrientation: AVCaptureVideoOrientation
505
+ var videoOrientation: AVCaptureVideoOrientation
534
506
 
535
507
  // Use window scene interface orientation
536
508
  if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
@@ -551,6 +523,8 @@ extension CameraController {
551
523
  } else {
552
524
  videoOrientation = .portrait
553
525
  }
526
+
527
+ videoOrientation = .landscapeLeft
554
528
 
555
529
  previewLayer?.connection?.videoOrientation = videoOrientation
556
530
  dataOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "7.6.0",
3
+ "version": "7.6.1-alpha.2",
4
4
  "description": "Camera preview",
5
5
  "license": "MIT",
6
6
  "repository": {