Skip to content

Commit

Permalink
viewer initialization: Fix 0 initial value not working as expected
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
christiankaindl authored Jan 13, 2024
1 parent f9aa957 commit 50a2841
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ const ReactPhotoSphereViewer = forwardRef<ViewerAPI, Props>((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,
Expand Down

0 comments on commit 50a2841

Please sign in to comment.