From 50a28412f63d7a88418674aa18f7dcd514537d89 Mon Sep 17 00:00:00 2001 From: Christian Kaindl Date: Sat, 13 Jan 2024 11:05:49 +0100 Subject: [PATCH] viewer initialization: Fix `0` initial value not working as expected For some properties, like `defaultZoomLvl`, the supported values range between 0-100. This change fixes the initialization when setting them to "0", which previously used the default instead, because of usage of `||`. Fix this by using `??` instead. --- src/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 783f8a2..814f16e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -250,11 +250,11 @@ const ReactPhotoSphereViewer = forwardRef((props, ref): React. width: options.width || "100px" }, fisheye: options.littlePlanet ? LITTLEPLANET_FISHEYE : options.fisheye || false, - minFov: options.minFov || 30, - maxFov: options.littlePlanet ? LITTLEPLANET_MAX_ZOOM : options.maxFov || 90, - defaultZoomLvl: options.littlePlanet ? LITTLEPLANET_DEF_ZOOM : options.defaultZoomLvl || 50, - defaultYaw: options.defaultYaw || 0, - defaultPitch: options.littlePlanet ? LITTLEPLANET_DEF_LAT : options.defaultPitch || 0, + minFov: options.minFov ?? 30, + maxFov: options.littlePlanet ? LITTLEPLANET_MAX_ZOOM : options.maxFov ?? 90, + defaultZoomLvl: options.littlePlanet ? LITTLEPLANET_DEF_ZOOM : options.defaultZoomLvl ?? 50, + defaultYaw: options.defaultYaw ?? 0, + defaultPitch: options.littlePlanet ? LITTLEPLANET_DEF_LAT : options.defaultPitch ?? 0, sphereCorrection: options.sphereCorrection || { pan: 0, tilt: 0, roll: 0 }, moveSpeed: options.moveSpeed || 1, zoomSpeed: options.zoomSpeed || 1,