WorldWideTelescope / wwt-web-client

The WorldWide Telescope web client lets you explore the universe in your browser.
https://worldwidetelescope.org/webclient/
MIT License
104 stars 35 forks source link

Initialize layer property sliders with current value #354

Closed Carifio24 closed 2 years ago

Carifio24 commented 2 years ago

While working with a catalog in the webclient, I noticed a bug with the DataVizController (which opens when you right click a layer and select properties). This window has two sliders that control scale factor and time decay. When the window is opened, both sliders are initialized with their default values (1 for scale factor, 16 for time decay), regardless of the current value for the layer.

Changing this to use the current value was a pretty quick fix. The code now checks, in order, the property value in the current scope, the current layer value, and the default, and uses the first one that isn't null or undefined (I went with == null rather than using nullish coalescing since IE doesn't support it). It then translates that into a pixel value for the CSS by just undoing what happens in onmove, with rounding for safety.