Skip to content

Commit e226a61

Browse files
authored
fix: Don't start zoom animation if we are already on that exact zoom value (#3988)
* fix: Don't start zoom animation if we are already on that exact `zoom` value * fix: Observe zoom ramp old and new values
1 parent 2c988e4 commit e226a61

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/react-native-vision-camera/ios/Hybrid Objects/HybridCameraController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,16 @@ final class HybridCameraController: HybridCameraControllerSpec, NativeCameraCont
321321

322322
func startZoomAnimation(zoom: Double, rate: Double) -> Promise<Void> {
323323
return captureDevice.withLock(queue) { completion in
324+
if self.captureDevice.videoZoomFactor == zoom {
325+
// We are already exactly on our target value
326+
completion()
327+
return
328+
}
329+
324330
var observation: NSKeyValueObservation?
325331
observation = self.captureDevice.observe(
326332
\.isRampingVideoZoom,
333+
options: [.old, .new],
327334
changeHandler: { _, change in
328335
if change.oldValue == true && change.newValue == false {
329336
completion()

0 commit comments

Comments
 (0)