Elius94 / react-photo-sphere-viewer

Photosphere Viewer for React.JS
MIT License
69 stars 21 forks source link

viewer initialization: Fix `0` initial value not working as expected #46

Closed christiankaindl closed 10 months ago

christiankaindl commented 10 months ago

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. The reproduction is very simple: initialize defaultZoomLvl, minFov or maxFov to "0" and observe it instead using their default value instead of "0". Change it to "1" and observe the value being initialized correctly.

Codesandbox reproduction: https://codesandbox.io/p/sandbox/photo-sphere-viewer-initialization-bug-repro-ch9952?file=%2Fsrc%2FApp.js%3A65%2C1-66%2C1

Note: For defaultYaw and defaultPitch the default is already "0", so this change doesn't make a difference, but I kept it in for correctness and consistency.

Elius94 commented 10 months ago

Thanks!